CenterRoleMapper.xml
3.11 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
<?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="org.nafmii.admin.user.dao.CenterRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="org.nafmii.admin.user.entity.CenterRolePO">
<id column="ID" property="id" />
<result column="R_NAME" property="rName" />
<result column="CREAT_TIME" property="creatTime" />
<result column="UPDATE_TIME" property="updateTime" />
<result column="IS_ENABLE" property="isEnable" />
<result column="CREATE_USER_ID" property="createUserId" />
<result column="UPDATE_USER_ID" property="updateUserId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID, R_NAME, CREAT_TIME, UPDATE_TIME, IS_ENABLE, CREATE_USER_ID, UPDATE_USER_ID
</sql>
<!-- 修改中心端角色 -->
<update id="updateRoleById" parameterType="map" >
update CENTER_ROLE
<set >
<if test="rName != null" >
R_NAME = #{rName,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
UPDATE_TIME = #{updateTime,jdbcType=DATE},
</if>
<if test="isEnable != null" >
IS_ENABLE = #{isEnable,jdbcType=VARCHAR},
</if>
<if test="updateUserId != null" >
UPDATE_USER_ID = #{updateUserId,jdbcType=BIGINT},
</if>
</set>
where ID = #{id,jdbcType=VARCHAR}
</update>
<!-- 查询中心端角色列表 -->
<select id="queryRolesList" parameterType="org.nafmii.admin.user.dto.QueryRolesDto"
resultType="org.nafmii.admin.user.vo.CenterRoleVO">
SELECT
ID as id, R_NAME as rName, CREAT_TIME as creatTime, UPDATE_TIME as updateTime, IS_ENABLE as isEnable,
CREATE_USER_ID as createUserId, UPDATE_USER_ID as updateUserId
FROM
CENTER_ROLE
<where>
<if test="startCreateTime != null and endCreateTime != null">
DATE_FORMAT(CREAT_TIME,'%Y-%m-%d') BETWEEN #{startCreateTime} and #{endCreateTime}
</if>
</where>
</select>
<!-- 删除中心端角色 -->
<update id="deleteRoles">
update
CENTER_ROLE
set IS_ENABLE = "1"
where ID IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 中心端用户对应角色查询 -->
<select id="queryRolesByUser" parameterType="map" resultType="org.nafmii.admin.user.vo.CenterRoleVO">
SELECT
cr.ID as id,
cr.R_NAME as rName,
cr.CREAT_TIME as creatTime,
cr.UPDATE_TIME as updateTime,
cr.IS_ENABLE as isEnable,
cr.CREATE_USER_ID as createUserId,
cr.UPDATE_USER_ID as updateUserId
FROM
CENTER_ROLE cr
INNER JOIN CENTER_USER_ROLE cur ON cur.role_id = cr.id
INNER JOIN CENTER_USER cu ON cur.user_id = cu.id
WHERE
cu.id = #{userid,jdbcType=BIGINT}
</select>
</mapper>