提交 | 用户 | 时间
|
fd2207
|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
懒 |
2 |
<!DOCTYPE mapper |
|
3 |
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
4 |
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
5 |
<mapper namespace="com.jcdm.system.mapper.SysMenuMapper"> |
|
6 |
|
|
7 |
<resultMap type="SysMenu" id="SysMenuResult"> |
|
8 |
<id property="menuId" column="menu_id" /> |
|
9 |
<result property="menuName" column="menu_name" /> |
|
10 |
<result property="parentName" column="parent_name" /> |
|
11 |
<result property="parentId" column="parent_id" /> |
|
12 |
<result property="orderNum" column="order_num" /> |
|
13 |
<result property="path" column="path" /> |
|
14 |
<result property="component" column="component" /> |
|
15 |
<result property="query" column="query" /> |
|
16 |
<result property="isFrame" column="is_frame" /> |
|
17 |
<result property="isCache" column="is_cache" /> |
|
18 |
<result property="menuType" column="menu_type" /> |
|
19 |
<result property="visible" column="visible" /> |
|
20 |
<result property="status" column="status" /> |
|
21 |
<result property="perms" column="perms" /> |
|
22 |
<result property="icon" column="icon" /> |
|
23 |
<result property="createBy" column="create_by" /> |
|
24 |
<result property="createTime" column="create_time" /> |
|
25 |
<result property="updateTime" column="update_time" /> |
|
26 |
<result property="updateBy" column="update_by" /> |
|
27 |
<result property="remark" column="remark" /> |
|
28 |
</resultMap> |
|
29 |
|
|
30 |
<sql id="selectMenuVo"> |
|
31 |
select menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, isnull(perms,'') as perms, icon, create_time |
|
32 |
from sys_menu |
|
33 |
</sql> |
|
34 |
|
|
35 |
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult"> |
|
36 |
<include refid="selectMenuVo"/> |
|
37 |
<where> |
|
38 |
<if test="menuName != null and menuName != ''"> |
|
39 |
AND menu_name like concat('%', #{menuName}, '%') |
|
40 |
</if> |
|
41 |
<if test="visible != null and visible != ''"> |
|
42 |
AND visible = #{visible} |
|
43 |
</if> |
|
44 |
<if test="status != null and status != ''"> |
|
45 |
AND status = #{status} |
|
46 |
</if> |
|
47 |
</where> |
|
48 |
order by parent_id, order_num |
|
49 |
</select> |
|
50 |
|
|
51 |
<select id="selectMenuTreeAll" resultMap="SysMenuResult"> |
|
52 |
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, isnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time |
|
53 |
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 |
|
54 |
order by m.parent_id, m.order_num |
|
55 |
</select> |
|
56 |
|
|
57 |
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult"> |
|
58 |
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, isnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time |
|
59 |
from sys_menu m |
|
60 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
61 |
left join sys_user_role ur on rm.role_id = ur.role_id |
|
62 |
left join sys_role ro on ur.role_id = ro.role_id |
|
63 |
where ur.user_id = #{params.userId} |
|
64 |
<if test="menuName != null and menuName != ''"> |
|
65 |
AND m.menu_name like concat('%', #{menuName}, '%') |
|
66 |
</if> |
|
67 |
<if test="visible != null and visible != ''"> |
|
68 |
AND m.visible = #{visible} |
|
69 |
</if> |
|
70 |
<if test="status != null and status != ''"> |
|
71 |
AND m.status = #{status} |
|
72 |
</if> |
|
73 |
order by m.parent_id, m.order_num |
|
74 |
</select> |
|
75 |
|
|
76 |
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult"> |
|
77 |
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, isnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time |
|
78 |
from sys_menu m |
|
79 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
80 |
left join sys_user_role ur on rm.role_id = ur.role_id |
|
81 |
left join sys_role ro on ur.role_id = ro.role_id |
|
82 |
left join sys_user u on ur.user_id = u.user_id |
|
83 |
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0 |
|
84 |
order by m.parent_id, m.order_num |
|
85 |
</select> |
|
86 |
|
|
87 |
<select id="selectMenuListByRoleId" resultType="Long"> |
|
88 |
select m.menu_id |
|
89 |
from sys_menu m |
|
90 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
91 |
where rm.role_id = #{roleId} |
|
92 |
<if test="menuCheckStrictly"> |
|
93 |
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId}) |
|
94 |
</if> |
|
95 |
order by m.parent_id, m.order_num |
|
96 |
</select> |
|
97 |
|
|
98 |
<select id="selectMenuPerms" resultType="String"> |
|
99 |
select distinct m.perms |
|
100 |
from sys_menu m |
|
101 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
102 |
left join sys_user_role ur on rm.role_id = ur.role_id |
|
103 |
</select> |
|
104 |
|
|
105 |
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String"> |
|
106 |
select distinct m.perms |
|
107 |
from sys_menu m |
|
108 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
109 |
left join sys_user_role ur on rm.role_id = ur.role_id |
|
110 |
left join sys_role r on r.role_id = ur.role_id |
|
111 |
where m.status = '0' and r.status = '0' and ur.user_id = #{userId} |
|
112 |
</select> |
|
113 |
|
|
114 |
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String"> |
|
115 |
select distinct m.perms |
|
116 |
from sys_menu m |
|
117 |
left join sys_role_menu rm on m.menu_id = rm.menu_id |
|
118 |
where m.status = '0' and rm.role_id = #{roleId} |
|
119 |
</select> |
|
120 |
|
|
121 |
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult"> |
|
122 |
<include refid="selectMenuVo"/> |
|
123 |
where menu_id = #{menuId} |
|
124 |
</select> |
|
125 |
|
|
126 |
<select id="hasChildByMenuId" resultType="Integer"> |
|
127 |
select count(1) from sys_menu where parent_id = #{menuId} |
|
128 |
</select> |
|
129 |
|
|
130 |
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult"> |
|
131 |
select top(1) menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, isnull(perms,'') as perms, icon, create_time |
|
132 |
from sys_menu |
|
133 |
where menu_name=#{menuName} and parent_id = #{parentId} |
|
134 |
</select> |
|
135 |
|
|
136 |
<update id="updateMenu" parameterType="SysMenu"> |
|
137 |
update sys_menu |
|
138 |
<set> |
|
139 |
<if test="menuName != null and menuName != ''">menu_name = #{menuName},</if> |
|
140 |
<if test="parentId != null">parent_id = #{parentId},</if> |
|
141 |
<if test="orderNum != null">order_num = #{orderNum},</if> |
|
142 |
<if test="path != null and path != ''">path = #{path},</if> |
|
143 |
<if test="component != null">component = #{component},</if> |
|
144 |
<if test="query != null"> query = #{query},</if> |
|
145 |
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if> |
|
146 |
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if> |
|
147 |
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if> |
|
148 |
<if test="visible != null">visible = #{visible},</if> |
|
149 |
<if test="status != null">status = #{status},</if> |
|
150 |
<if test="perms !=null">perms = #{perms},</if> |
|
151 |
<if test="icon !=null and icon != ''">icon = #{icon},</if> |
|
152 |
<if test="remark != null and remark != ''">remark = #{remark},</if> |
|
153 |
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|
154 |
update_time = getdate() |
|
155 |
</set> |
|
156 |
where menu_id = #{menuId} |
|
157 |
</update> |
|
158 |
|
|
159 |
<insert id="insertMenu" parameterType="SysMenu"> |
|
160 |
insert into sys_menu( |
|
161 |
<if test="menuId != null and menuId != 0">menu_id,</if> |
|
162 |
<if test="parentId != null and parentId != 0">parent_id,</if> |
|
163 |
<if test="menuName != null and menuName != ''">menu_name,</if> |
|
164 |
<if test="orderNum != null">order_num,</if> |
|
165 |
<if test="path != null and path != ''">path,</if> |
|
166 |
<if test="component != null and component != ''">component,</if> |
|
167 |
<if test="query != null and query != ''">query,</if> |
|
168 |
<if test="isFrame != null and isFrame != ''">is_frame,</if> |
|
169 |
<if test="isCache != null and isCache != ''">is_cache,</if> |
|
170 |
<if test="menuType != null and menuType != ''">menu_type,</if> |
|
171 |
<if test="visible != null">visible,</if> |
|
172 |
<if test="status != null">status,</if> |
|
173 |
<if test="perms !=null and perms != ''">perms,</if> |
|
174 |
<if test="icon != null and icon != ''">icon,</if> |
|
175 |
<if test="remark != null and remark != ''">remark,</if> |
|
176 |
<if test="createBy != null and createBy != ''">create_by,</if> |
|
177 |
create_time |
|
178 |
)values( |
|
179 |
<if test="menuId != null and menuId != 0">#{menuId},</if> |
|
180 |
<if test="parentId != null and parentId != 0">#{parentId},</if> |
|
181 |
<if test="menuName != null and menuName != ''">#{menuName},</if> |
|
182 |
<if test="orderNum != null">#{orderNum},</if> |
|
183 |
<if test="path != null and path != ''">#{path},</if> |
|
184 |
<if test="component != null and component != ''">#{component},</if> |
|
185 |
<if test="query != null and query != ''">#{query},</if> |
|
186 |
<if test="isFrame != null and isFrame != ''">#{isFrame},</if> |
|
187 |
<if test="isCache != null and isCache != ''">#{isCache},</if> |
|
188 |
<if test="menuType != null and menuType != ''">#{menuType},</if> |
|
189 |
<if test="visible != null">#{visible},</if> |
|
190 |
<if test="status != null">#{status},</if> |
|
191 |
<if test="perms !=null and perms != ''">#{perms},</if> |
|
192 |
<if test="icon != null and icon != ''">#{icon},</if> |
|
193 |
<if test="remark != null and remark != ''">#{remark},</if> |
|
194 |
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|
195 |
getdate() |
|
196 |
) |
|
197 |
</insert> |
|
198 |
|
|
199 |
<delete id="deleteMenuById" parameterType="Long"> |
|
200 |
delete from sys_menu where menu_id = #{menuId} |
|
201 |
</delete> |
|
202 |
|
|
203 |
</mapper> |