MenuMapper.xml
7.14 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
<?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.neshield.modules.mapper.MenuMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.neshield.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.neshield.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="selectDTOList" resultMap="DTOResultMap">
select
<include refid="Base_Column_List"/>
from t_menu
where del_flag = 0
<if test="name != null and name != ''">
and menu_name LIKE CONCAT('%',#{name},'%')
</if>
<if test="enableStatus != null">
and enable_status = #{enableStatus}
</if>
<choose>
<when test="parentId !=null">
and parent_id LIKE CONCAT(#{parentId},'%')
</when>
<otherwise>
and type = 1
</otherwise>
</choose>
order by order_num
</select>
<select id="selectMenuFullTree" resultType="cn.com.glsx.neshield.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.neshield.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="roleId" open="(" close=")" separator=",">
#{roleId}
</foreach>
</if>
<if test="menuIds != null and menuIds.size() > 0">
and m.id in
<foreach collection="menuIds" item="menuId" open="(" close=")" separator=",">
#{menuId}
</foreach>
</if>
<if test="menuTypes != null and menuTypes.size() > 0">
and m.type in
<foreach collection="menuTypes" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
</if>
</select>
<select id="selectMenuTreeByParentId" resultType="cn.com.glsx.neshield.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,t_role_menu rm
where m.id = 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="selectList" resultMap="BaseResultMap">
select
m.id,
m.menu_no,
m.menu_name,
m.front_route,
m.permission_tag,
m.parent_id,
m.`type`,
m.icon,
m.order_num,
m.enable_status,
m.del_flag,
m.created_date,
m.created_by,
m.updated_date,
m.updated_by
from t_menu m,t_role_menu rm
where m.id = 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>
</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>
</mapper>