1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?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.landtool.lanbase.modules.sys.dao.SysMenuDao">
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select * from SYS_MENU where id = #{value}
    </select>
    
    <insert id="save" parameterType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        insert into SYS_MENU
        (
            parent_id, 
            name, 
            url, 
            perms, 
            type, 
            icon, 
            order_num,
            isshow,
            target
        )
        values
        (
            #{parentId}, 
            #{name}, 
            #{url,jdbcType=VARCHAR}, 
            #{perms,jdbcType=VARCHAR},
            #{type},
            #{icon,jdbcType=VARCHAR},
            #{orderNum},
            #{isshow},
            #{target}
        )
    </insert>
    
    <select id="queryListByParentId" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select * from SYS_MENU where parent_id = #{parentId}  and isshow=1 order by order_num asc
    </select>
    
    <select id="queryNotButtonList" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select * from SYS_MENU where type != 2  order by order_num asc
    </select>
    
    <select id="queryList" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select tmp.*,row_number() over() as rownumber from (
            select m.*,p.name as parentName from SYS_MENU m
            left join SYS_MENU p on p.id = m.parent_id
            <where>
                <if test="name != null and name != ''">
                    AND (m.name LIKE ('%' || #{name} || '%') and m.parent_id = 0)
                </if>
                <if test="type != null">
                    AND (m.type = #{type} and m.parent_id = 0)
                </if>
                <if test="perms != null and perms != ''">
                    AND (m.perms LIKE ('%' || #{perms} || '%') and m.parent_id = 0)
                </if>
                <if test="parentName != null and parentName != ''">
                    AND (p.name LIKE ('%' || #{parentName} || '%') and m.parent_id != 0)
                </if>
            </where>
        ) tmp order by rownumber
    </select>
    
    <select id="queryChildList" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select m.id,0 as parent_id,m.icon,m.name,m.url,m.perms,m.type,m.order_num,m.isshow,p.name as parentName from SYS_MENU m
        left join SYS_MENU p on p.id = m.parent_id
        <where>
            <if test="name != null and name != ''">
                 AND (m.name LIKE ('%' || #{name} || '%') and m.parent_id != 0)
            </if>
            <if test="type != null">
                 AND (m.type = #{type} and m.parent_id != 0)
            </if>
            <if test="perms != null and perms != ''">
                 AND (m.perms LIKE ('%' || #{perms} || '%') and m.parent_id != 0)
            </if>
            <if test="parentName != null and parentName != ''">
                 AND (p.name LIKE ('%' || #{parentName} || '%') and m.parent_id != 0)
            </if>
        </where>
        order by order_num
    </select>
    
    <!-- 查询用户的权限列表 --> 
    <select id="queryUserList" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select distinct m.*,p.name as parentName from SYS_USER_ROLE ur
        left join SYS_MENU p on p.id = m.parent_id
        left join SYS_ROLE_MENU rm on ur.role_id = rm.role_id
        left join SYS_MENU m on rm.menu_id = m.id
        where ur.user_id = #{userId} order by m.order_num asc
    </select>
    
    <select id="queryTotal" resultType="int">
        select count(*) from SYS_MENU
    </select>
     
    <update id="update" parameterType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        update SYS_MENU
        <set> 
            <if test="parentId != null">parent_id = #{parentId}, </if>
            <if test="name != null">name = #{name}, </if>
            <if test="url != null">url = #{url}, </if>
            <if test="perms != null">perms = #{perms}, </if>
            <if test="type != null">type = #{type}, </if>
            <if test="icon != null">icon = #{icon}, </if>
            <if test="orderNum != null">order_num = #{orderNum}, </if>
            <if test="isshow != null">isshow = #{isshow}, </if>
            <if test="target != null">target = #{target}</if>
        </set>
        where id = #{id}
    </update>
    
    
    <delete id="deleteBatch">
        delete from SYS_MENU where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
        <!-- 删除子节点 -->
    <!-- ; 
        delete from sys_menu where parent_Id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach -->
        
    </delete>
    
    <select id="queryUserWithSEQ" resultType="int">
        SELECT currval('SYS_MENU_INS_SEQ') FROM DUAL
    </select>
    
    <select id="queryNoButtonListByParentId" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select * from SYS_MENU where parent_id = #{parentId} and isshow=1 and type!=2  order by order_num asc
    </select>
    
    <update id="updateRorder" parameterType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        update SYS_MENU
        <set>
            <if test="orderNum != null">order_num = #{orderNum} </if>
        </set>
        where id = #{id}
    </update>
    
    <select id="queryMaxRorder" resultType="int">
        select case when max(order_num) > 0 then max(order_num) else 0 end as rorder from SYS_MENU where parent_id=#{parentId}
    </select>
    
    <select id="queryAllListByParentId" resultType="com.landtool.lanbase.modules.sys.entity.SysMenu">
        select * from SYS_MENU where parent_id = #{parentId} order by order_num asc
    </select>
</mapper>