提交 | 用户 | 时间
|
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.SysRoleMapper"> |
|
6 |
|
|
7 |
<resultMap type="SysRole" id="SysRoleResult"> |
|
8 |
<id property="roleId" column="role_id" /> |
|
9 |
<result property="roleName" column="role_name" /> |
|
10 |
<result property="roleKey" column="role_key" /> |
|
11 |
<result property="roleSort" column="role_sort" /> |
|
12 |
<result property="dataScope" column="data_scope" /> |
|
13 |
<result property="menuCheckStrictly" column="menu_check_strictly" /> |
|
14 |
<result property="deptCheckStrictly" column="dept_check_strictly" /> |
|
15 |
<result property="status" column="status" /> |
|
16 |
<result property="delFlag" column="del_flag" /> |
|
17 |
<result property="createBy" column="create_by" /> |
|
18 |
<result property="createTime" column="create_time" /> |
|
19 |
<result property="updateBy" column="update_by" /> |
|
20 |
<result property="updateTime" column="update_time" /> |
|
21 |
<result property="remark" column="remark" /> |
|
22 |
</resultMap> |
|
23 |
|
|
24 |
<sql id="selectRoleVo"> |
|
25 |
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, |
|
26 |
r.status, r.del_flag, r.create_time, r.remark |
|
27 |
from sys_role r |
|
28 |
left join sys_user_role ur on ur.role_id = r.role_id |
|
29 |
left join sys_user u on u.user_id = ur.user_id |
|
30 |
left join sys_dept d on u.dept_id = d.dept_id |
|
31 |
</sql> |
|
32 |
|
|
33 |
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> |
|
34 |
<include refid="selectRoleVo"/> |
|
35 |
where r.del_flag = '0' |
|
36 |
<if test="roleId != null and roleId != 0"> |
|
37 |
AND r.role_id = #{roleId} |
|
38 |
</if> |
|
39 |
<if test="roleName != null and roleName != ''"> |
|
40 |
AND r.role_name like concat('%', #{roleName}, '%') |
|
41 |
</if> |
|
42 |
<if test="status != null and status != ''"> |
|
43 |
AND r.status = #{status} |
|
44 |
</if> |
|
45 |
<if test="roleKey != null and roleKey != ''"> |
|
46 |
AND r.role_key like concat('%', #{roleKey}, '%') |
|
47 |
</if> |
|
48 |
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> |
|
49 |
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') |
|
50 |
</if> |
|
51 |
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> |
|
52 |
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') |
|
53 |
</if> |
|
54 |
<!-- 数据范围过滤 --> |
|
55 |
${params.dataScope} |
|
56 |
order by r.role_sort |
|
57 |
</select> |
|
58 |
|
|
59 |
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult"> |
|
60 |
<include refid="selectRoleVo"/> |
|
61 |
WHERE r.del_flag = '0' and ur.user_id = #{userId} |
|
62 |
</select> |
|
63 |
|
|
64 |
<select id="selectRoleAll" resultMap="SysRoleResult"> |
|
65 |
<include refid="selectRoleVo"/> |
|
66 |
</select> |
|
67 |
|
|
68 |
<select id="selectRoleListByUserId" parameterType="Long" resultType="Long"> |
|
69 |
select r.role_id |
|
70 |
from sys_role r |
|
71 |
left join sys_user_role ur on ur.role_id = r.role_id |
|
72 |
left join sys_user u on u.user_id = ur.user_id |
|
73 |
where u.user_id = #{userId} |
|
74 |
</select> |
|
75 |
|
|
76 |
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> |
|
77 |
<include refid="selectRoleVo"/> |
|
78 |
where r.role_id = #{roleId} |
|
79 |
</select> |
|
80 |
|
|
81 |
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult"> |
|
82 |
<include refid="selectRoleVo"/> |
|
83 |
WHERE r.del_flag = '0' and u.user_name = #{userName} |
|
84 |
</select> |
|
85 |
|
|
86 |
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult"> |
|
87 |
<!-- <include refid="selectRoleVo"/>--> |
|
88 |
<!-- where r.role_name=#{roleName} and r.del_flag = '0' limit 1--> |
|
89 |
select distinct top(1) r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, |
|
90 |
r.status, r.del_flag, r.create_time, r.remark |
|
91 |
from sys_role r |
|
92 |
left join sys_user_role ur on ur.role_id = r.role_id |
|
93 |
left join sys_user u on u.user_id = ur.user_id |
|
94 |
left join sys_dept d on u.dept_id = d.dept_id |
|
95 |
where r.role_name=#{roleName} and r.del_flag = '0' |
|
96 |
</select> |
|
97 |
|
|
98 |
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult"> |
|
99 |
<!-- <include refid="selectRoleVo"/>--> |
|
100 |
<!-- where r.role_key=#{roleKey} and r.del_flag = '0' limit 1--> |
|
101 |
select distinct top(1) r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, |
|
102 |
r.status, r.del_flag, r.create_time, r.remark |
|
103 |
from sys_role r |
|
104 |
left join sys_user_role ur on ur.role_id = r.role_id |
|
105 |
left join sys_user u on u.user_id = ur.user_id |
|
106 |
left join sys_dept d on u.dept_id = d.dept_id |
|
107 |
where r.role_key=#{roleKey} and r.del_flag = '0' |
|
108 |
</select> |
|
109 |
|
|
110 |
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> |
|
111 |
insert into sys_role( |
|
112 |
<if test="roleId != null and roleId != 0">role_id,</if> |
|
113 |
<if test="roleName != null and roleName != ''">role_name,</if> |
|
114 |
<if test="roleKey != null and roleKey != ''">role_key,</if> |
|
115 |
<if test="roleSort != null">role_sort,</if> |
|
116 |
<if test="dataScope != null and dataScope != ''">data_scope,</if> |
|
117 |
<if test="menuCheckStrictly != null">menu_check_strictly,</if> |
|
118 |
<if test="deptCheckStrictly != null">dept_check_strictly,</if> |
|
119 |
<if test="status != null and status != ''">status,</if> |
|
120 |
<if test="remark != null and remark != ''">remark,</if> |
|
121 |
<if test="createBy != null and createBy != ''">create_by,</if> |
|
122 |
create_time |
|
123 |
)values( |
|
124 |
<if test="roleId != null and roleId != 0">#{roleId},</if> |
|
125 |
<if test="roleName != null and roleName != ''">#{roleName},</if> |
|
126 |
<if test="roleKey != null and roleKey != ''">#{roleKey},</if> |
|
127 |
<if test="roleSort != null">#{roleSort},</if> |
|
128 |
<if test="dataScope != null and dataScope != ''">#{dataScope},</if> |
|
129 |
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if> |
|
130 |
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if> |
|
131 |
<if test="status != null and status != ''">#{status},</if> |
|
132 |
<if test="remark != null and remark != ''">#{remark},</if> |
|
133 |
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|
134 |
getdate() |
|
135 |
) |
|
136 |
</insert> |
|
137 |
|
|
138 |
<update id="updateRole" parameterType="SysRole"> |
|
139 |
update sys_role |
|
140 |
<set> |
|
141 |
<if test="roleName != null and roleName != ''">role_name = #{roleName},</if> |
|
142 |
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if> |
|
143 |
<if test="roleSort != null">role_sort = #{roleSort},</if> |
|
144 |
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if> |
|
145 |
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if> |
|
146 |
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if> |
|
147 |
<if test="status != null and status != ''">status = #{status},</if> |
|
148 |
<if test="remark != null">remark = #{remark},</if> |
|
149 |
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|
150 |
update_time = getdate() |
|
151 |
</set> |
|
152 |
where role_id = #{roleId} |
|
153 |
</update> |
|
154 |
|
|
155 |
<delete id="deleteRoleById" parameterType="Long"> |
|
156 |
update sys_role set del_flag = '2' where role_id = #{roleId} |
|
157 |
</delete> |
|
158 |
|
|
159 |
<delete id="deleteRoleByIds" parameterType="Long"> |
|
160 |
update sys_role set del_flag = '2' where role_id in |
|
161 |
<foreach collection="array" item="roleId" open="(" separator="," close=")"> |
|
162 |
#{roleId} |
|
163 |
</foreach> |
|
164 |
</delete> |
|
165 |
|
|
166 |
</mapper> |