forked from kidgrow-microservices-platform

zhaoxiaohao
2020-05-14 eaf5199c2eee33f5add31d6dbe17d731eb9eab66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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.kidgrow.usercenter.mapper.SysRoleMenuMapper">
 
    <update id="delete">
        delete from sys_role_menu
        <where>
            <if test="roleId != null">
                and role_id = #{roleId}
            </if>
            <if test="menuId != null">
                and menu_id = #{menuId}
            </if>
        </where>
    </update>
 
    <select id="findMenusByRoleIds" 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
        where
        r.role_id in
        <foreach collection="roleIds" index="index" item="roleId"
            open="(" separator="," close=")">
            #{roleId}
        </foreach>
        <if test="type != null">
            and t.type = #{type}
        </if>
        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>
            and t.hidden = 0
            and t.enabled = 1
            ORDER BY sort ASC
        </select>
</mapper>