MenuMapper.xml
8.48 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?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="cn.com.glsx.shield.modules.mapper.MenuMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.shield.modules.entity.Menu">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="menu_no" jdbcType="INTEGER" property="menuNo"/>
<result column="menu_name" jdbcType="VARCHAR" property="menuName"/>
<result column="front_route" jdbcType="VARCHAR" property="frontRoute"/>
<result column="permission_tag" jdbcType="VARCHAR" property="permissionTag"/>
<result column="parent_id" jdbcType="INTEGER" property="parentId"/>
<result column="type" jdbcType="TINYINT" property="type"/>
<result column="icon" jdbcType="VARCHAR" property="icon"/>
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
<result column="enable_status" jdbcType="TINYINT" property="enableStatus"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.shield.modules.model.view.MenuDTO">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="menu_no" jdbcType="INTEGER" property="menuNo"/>
<result column="menu_name" jdbcType="VARCHAR" property="menuName"/>
<result column="front_route" jdbcType="VARCHAR" property="frontRoute"/>
<result column="permission_tag" jdbcType="VARCHAR" property="permissionTag"/>
<result column="parent_id" jdbcType="INTEGER" property="parentId"/>
<result column="type" jdbcType="TINYINT" property="type"/>
<result column="icon" jdbcType="VARCHAR" property="icon"/>
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
<result column="enable_status" jdbcType="TINYINT" property="enableStatus"/>
</resultMap>
<sql id="Base_Column_List">
id
, menu_no, menu_name, front_route, permission_tag, parent_id, `type`, icon, order_num, enable_status,
del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_menu
where id = #{id}
and del_flag = 0
</select>
<select id="selectByMenuNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_menu
where menu_no = #{menuNo}
and del_flag = 0
</select>
<update id="logicDeleteById">
update t_menu
set del_flag = -1
where id = #{id}
</update>
<select id="search" resultMap="DTOResultMap">
select distinct tm.id,tm.menu_no,tm.menu_name,tm.front_route,tm.permission_tag,
tm.parent_id,tm.type,tm.icon,tm.order_num,tm.enable_status
from t_menu tm
left join t_role_menu trm on trm.menu_id = tm.menu_no
where tm.del_flag = 0 and trm.del_flag = 0
<if test="name != null and name != ''">
and tm.menu_name LIKE CONCAT('%',#{name},'%')
</if>
<if test="enableStatus != null">
and tm.enable_status = #{enableStatus}
</if>
<choose>
<when test="parentId !=null">
and tm.parent_id LIKE CONCAT(#{parentId},'%')
</when>
<otherwise>
and tm.type = 1
</otherwise>
</choose>
and trm.role_id in
<foreach collection="roleIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
order by tm.order_num
</select>
<select id="selectChildren" resultMap="DTOResultMap">
select distinct tm.id,tm.menu_no,tm.menu_name,tm.front_route,tm.permission_tag,
tm.parent_id,tm.type,tm.icon,tm.order_num,tm.enable_status
from t_menu tm
left join t_role_menu trm on trm.menu_id = tm.menu_no
where tm.del_flag = 0 and trm.del_flag = 0
and tm.parent_id = #{parentId}
<if test="name != null and name != ''">
and tm.menu_name LIKE CONCAT('%',#{name},'%')
</if>
<if test="enableStatus != null">
and tm.enable_status = #{enableStatus}
</if>
and trm.role_id in
<foreach collection="roleIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
order by tm.order_num
</select>
<select id="selectMenuFullTree" resultType="cn.com.glsx.shield.modules.model.MenuModel">
select m.menu_no menuNo, m.parent_id parentId, m.menu_name menuName, m.order_num orderNum, m.type, m.icon
from t_menu m
where m.del_flag = 0
and m.enable_status = 1
</select>
<select id="selectMenuPermTree" resultType="cn.com.glsx.shield.modules.model.MenuModel">
select m.menu_no menuNo,m.parent_id parentId,m.menu_name menuName,m.order_num orderNum,
m.type,m.front_route frontRoute,m.icon
from t_menu m,t_role_menu rm
where m.menu_no = rm.menu_id
and m.del_flag = 0
and rm.del_flag = 0
and m.enable_status = 1
<if test="roleIds != null and roleIds.size() > 0">
and rm.role_id in
<foreach collection="roleIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="menuIds != null and menuIds.size() > 0">
and m.id in
<foreach collection="menuIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="menuTypes != null and menuTypes.size() > 0">
and m.type in
<foreach collection="menuTypes" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="selectMenuTreeByParentId" resultType="cn.com.glsx.shield.modules.model.MenuModel">
select m.menu_no menuNo,m.parent_id parentId,
m.menu_name menuName,
m.permission_tag permissionTag,
m.order_num orderNum,m.type,m.icon
from t_menu m,t_role_menu rm
where m.menu_no = rm.menu_id
and m.del_flag = 0
and rm.del_flag = 0
and m.enable_status = 1
<if test="roleIds != null and roleIds.size() > 0">
and rm.role_id in
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
#{roleId}
</foreach>
</if>
and m.parent_id = #{parentNo}
</select>
<select id="selectByParentId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_menu
where parent_id = #{parentNo}
and del_flag = 0
order by order_num
</select>
<select id="selectByLikeParentNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_menu
where menu_no like #{parentNo}
and del_flag = 0
order by order_num
</select>
<select id="selectChildrenCntByParentId" resultType="java.lang.Integer">
select count(1)
from t_menu
where parent_id = #{parentNo}
and del_flag = 0
</select>
<select id="getMenuByPermissionTag" resultType="cn.com.glsx.usercenter.api.dto.response.MenuDto">
select turr.user_id as userId ,
turr.role_id as roleId,
tm.menu_no as menuNo,
tm.menu_name as menuName,
tm.permission_tag as permissionTag
from t_role_menu trm
left join t_menu tm on trm.menu_id = tm.menu_no
left join t_user_role_relation turr on trm.role_id = turr.role_id
where trm.del_flag = 0
and tm.del_flag=0
and turr.del_flag = 0
and tm.enable_status = 1
<if test="permissionTag != null and permissionTag != ''">
and tm.permission_tag =#{permissionTag}
</if>
<if test="userIds != null and userIds.size() > 0">
and turr.user_id in
<foreach collection="userIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>