forked from kidgrow-microservices-platform

zhaoxiaohao
2020-08-13 0eb0c43113ed9c4585ba936dcbe87feb4df6ba24
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/resources/mapper/SysRoleMenuMapper.xml
@@ -3,7 +3,7 @@
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kidgrow.usercenter.mapper.SysRoleMenuMapper">
   <update id="delete">
   <delete id="delete">
      delete from sys_role_menu
      <where>
         <if test="roleId != null">
@@ -13,7 +13,7 @@
            and menu_id = #{menuId}
         </if>
      </where>
   </update>
   </delete>
   <select id="findMenusByRoleIds" resultType="com.kidgrow.common.model.SysMenu">
      select distinct t.* from sys_menu t
@@ -30,22 +30,42 @@
      ORDER BY sort ASC
   </select>
    <select id="findMenusByRoleCodes" resultType="com.kidgrow.common.model.SysMenu">
      select distinct t.* from sys_menu t
      inner join sys_role_menu r on r.menu_id = t.id
      inner join sys_role rl on rl.id = r.role_id and rl.tenant_id=#{tenantId} and rl.enabled=1
      where
      rl.code in
      <foreach collection="roleCodes" index="index" item="roleCode"
             open="(" separator="," close=")">
         #{roleCode}
      </foreach>
      <if test="type != null">
         and t.type = #{type}
      </if>
      and t.hidden = 0
      and t.tenant_id = #{tenantId}
      and t.enabled = 1
      ORDER BY sort ASC
   </select>
<!--    <select id="findMenusByRoleCodes" resultType="com.kidgrow.common.model.SysMenu">-->
<!--      select distinct t.* from sys_menu t-->
<!--      inner join sys_role_menu r on r.menu_id = t.id-->
<!--      inner join sys_role rl on rl.id = r.role_id and rl.tenant_id=#{tenantId} and rl.enabled=1-->
<!--      where-->
<!--      rl.code in-->
<!--      <foreach collection="roleCodes" index="index" item="roleCode"-->
<!--             open="(" separator="," close=")">-->
<!--         #{roleCode}-->
<!--      </foreach>-->
<!--      <if test="type != null">-->
<!--         and t.type = #{type}-->
<!--      </if>-->
<!--      and t.hidden = 0-->
<!--      and t.tenant_id = #{tenantId}-->
<!--      and t.enabled = 1-->
<!--      ORDER BY sort ASC-->
<!--   </select>-->
       <select id="findMenusByRoleCodes" resultType="com.kidgrow.common.model.SysMenu">
         select distinct t.* from sys_menu t
         inner join sys_role_menu r on r.menu_id = t.id
         inner join sys_role rl on rl.id = r.role_id  and rl.enabled=1
         where
         rl.code in
         <foreach collection="roleCodes" index="index" item="roleCode"
                open="(" separator="," close=")">
            #{roleCode}
         </foreach>
         <if test="type != null">
            and t.type = #{type}
         </if>
         <if test="tenantId != null and tenantId !=''">
            and t.tenant_id = #{tenantId}
         </if>
         and t.hidden = 0
         and t.enabled = 1
         ORDER BY sort ASC
      </select>
</mapper>