UserRoleMapper.xml
2.84 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
<?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.dj.system.mapper.UserRoleMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.UserRole" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="role_id" property="roleId" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.system.dto.UserRoleDTO" extends="BaseResultMap">
<result column="roleName" property="roleName" jdbcType="VARCHAR" />
<result column="roleDescription" property="roleDescription" jdbcType="VARCHAR" />
<result column="roleStatus" property="roleStatus" jdbcType="TINYINT" />
<result column="isSuper" property="isSuper" jdbcType="BIT"/>
<result column="roleCreatedUserId" property="roleCreatedUserId"/>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, role_id, user_id, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="countUserUse" parameterType="java.lang.Integer" resultType="java.lang.Long">
select count(0) from dj_system_user_role where deleted_flag='N' and role_id=#{roleId}
</select>
<select id="getUserIdsByRoleId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
select user_id from dj_system_user_role where deleted_flag='N' and role_id=#{roleId}
</select>
<select id="list" parameterType="cn.com.glsx.dj.system.dto.UserRoleDTO" resultMap="DTOResultMap">
select
a.role_id,a.user_id,
b.name roleName,b.description roleDescription,b.status roleStatus,b.is_super isSuper,b.created_user_id roleCreatedUserId
from dj_system_user_role a
join dj_system_role b on b.id=a.role_id
<where>
a.deleted_flag = 'N'
and b.deleted_flag = 'N'
<if test="userId != null">
and a.user_id = #{userId}
</if>
<if test="isSuper != null">
and b.is_super = #{isSuper}
</if>
<if test="roleStatus != null">
and b.status = #{roleStatus}
</if>
</where>
</select>
<update id="deleteByUserId" parameterType="cn.com.glsx.dj.system.dto.UserRoleDTO">
update dj_system_user_role set deleted_flag='D',updated_by=#{updatedBy},updated_date=#{updatedDate} where deleted_flag='N' and user_id = #{userId}
</update>
</mapper>