<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cool.store.mapper.SysRoleMenuMapper">

    <resultMap id="baseResult" type="com.cool.store.entity.SysRoleMenuDO">
        <result property="id" column="id"/>
        <result property="menuId" column="menu_id"/>
        <result property="roleId" column="role_id"/>
        <result property="platform" column="platform"/>
    </resultMap>

    <select id="listSysRoleMenuByRoleIdOld" resultMap="baseResult">
        select  * from
        sys_role_menu_${enterpriseId}
        where role_id=#{roleId} and platform=#{platform}
    </select>
    <select id="listSysRoleMenuByRoleId" resultMap="baseResult">
        select  * from
        sys_role_menu_v2_${enterpriseId}
        where role_id=#{roleId} and platform=#{platform}
    </select>

    <select id="listSysRoleMenuByPlatform" resultMap="baseResult">
        select  * from
        sys_role_menu_v2_${enterpriseId}
        where platform=#{platform}
        order by id asc
    </select>

    <select id="listSysRoleMenuIdByMenuId" resultType="java.lang.Long">
        select  DISTINCT role_id from
            sys_role_menu_v2_${enterpriseId}
        where menu_id=#{menuId} and platform=#{platform}

    </select>
    
    <select id="listRoleMenuIdByMenuIds" resultMap="baseResult">
        select  * from
        sys_role_menu_${enterpriseId}
        where
        menu_id in
        <foreach collection="menuIds" open="(" close=")" separator="," item="menuId">#{menuId}</foreach>
        order by id asc
    </select>

</mapper>