中国算力平台算力登记系统2.0
yanzhaofeige
2024-09-30 3c4fee1db116c11d4f04727cfe076d7c94daeaf2
commit | author | age
43dc29 1 <?xml version="1.0" encoding="UTF-8" ?>
Y 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.odcc.cpzidc.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') &gt;= 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') &lt;= 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>
90     
91     <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
92         <include refid="selectRoleVo"/>
93          where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
94     </select>
95     
96      <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
97          insert into sys_role(
98              <if test="roleId != null and roleId != 0">role_id,</if>
99              <if test="roleName != null and roleName != ''">role_name,</if>
100              <if test="roleKey != null and roleKey != ''">role_key,</if>
101              <if test="roleSort != null">role_sort,</if>
102              <if test="dataScope != null and dataScope != ''">data_scope,</if>
103              <if test="menuCheckStrictly != null">menu_check_strictly,</if>
104              <if test="deptCheckStrictly != null">dept_check_strictly,</if>
105              <if test="status != null and status != ''">status,</if>
106              <if test="remark != null and remark != ''">remark,</if>
107              <if test="createBy != null and createBy != ''">create_by,</if>
108              create_time
109          )values(
110              <if test="roleId != null and roleId != 0">#{roleId},</if>
111              <if test="roleName != null and roleName != ''">#{roleName},</if>
112              <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
113              <if test="roleSort != null">#{roleSort},</if>
114              <if test="dataScope != null and dataScope != ''">#{dataScope},</if>
115              <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
116              <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
117              <if test="status != null and status != ''">#{status},</if>
118              <if test="remark != null and remark != ''">#{remark},</if>
119              <if test="createBy != null and createBy != ''">#{createBy},</if>
120              sysdate()
121          )
122     </insert>
123     
124     <update id="updateRole" parameterType="SysRole">
125          update sys_role
126          <set>
127              <if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
128              <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
129              <if test="roleSort != null">role_sort = #{roleSort},</if>
130              <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
131              <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
132              <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
133              <if test="status != null and status != ''">status = #{status},</if>
134              <if test="remark != null">remark = #{remark},</if>
135              <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
136              update_time = sysdate()
137          </set>
138          where role_id = #{roleId}
139     </update>
140     
141     <delete id="deleteRoleById" parameterType="Long">
142          update sys_role set del_flag = '2' where role_id = #{roleId}
143      </delete>
144      
145      <delete id="deleteRoleByIds" parameterType="Long">
146          update sys_role set del_flag = '2' where role_id in
147          <foreach collection="array" item="roleId" open="(" separator="," close=")">
148              #{roleId}
149         </foreach> 
150      </delete>
151      
152 </mapper>