doum
2025-09-26 9057e04efad1b7d61c77a72e5c37a504d0aee935
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
<?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="com.doumee.dao.system.SystemRoleMapper">
 
  <!-- 查询角色列表 -->
  <resultMap id="SystemRoleListVO" type="com.doumee.dao.system.vo.SystemRoleListVO" autoMapping="true">
    <id column="ID" property="id"/>
    <association property="createUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
      <id column="CREATE_USER_ID" property="id"/>
      <result column="CREATE_USER_NAME" property="username"/>
    </association>
    <association property="updateUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
      <id column="UPDATE_USER_ID" property="id"/>
      <result column="UPDATE_USER_NAME" property="username"/>
    </association>
  </resultMap>
  <select id="selectManageList" parameterType="com.doumee.dao.system.dto.QuerySystemUserDTO" resultMap="SystemRoleListVO">
    SELECT
      role.ID, role.`CODE`, role.`NAME`, role.`REMARK`, role.`FIXED`, role.`CREATE_TIME`, role.`UPDATE_TIME`,
      create_user.ID CREATE_USER_ID, create_user.`USERNAME` CREATE_USER_NAME,
      update_user.ID UPDETE_USER_ID, update_user.`USERNAME` UPDATE_USER_NAME
    FROM SYSTEM_ROLE role
    LEFT JOIN `SYSTEM_USER` create_user ON create_user.ID = role.CREATE_USER
    LEFT JOIN `SYSTEM_USER` update_user ON update_user.ID = role.UPDATE_USER
    <where>
      role.DELETED = 0
      <if test="dto.code != null and dto.code != ''">
        AND role.`CODE` LIKE CONCAT('%', #{dto.code}, '%')
      </if>
      <if test="dto.name != null and dto.name != ''">
        AND role.`NAME` LIKE CONCAT('%', #{dto.name}, '%')
      </if>
    </where>
    ${orderByClause}
  </select>
 
  <!-- 查询用户角色列表 -->
  <select id="selectByUserId" parameterType="java.lang.Integer" resultType="com.doumee.dao.system.model.SystemRole">
    SELECT
    role.ID, role.`CODE`, role.`NAME`, role.`REMARK`, role.`CREATE_TIME`, role.`UPDATE_TIME`
    FROM SYSTEM_ROLE role
    INNER JOIN SYSTEM_USER_ROLE user_role ON user_role.ROLE_ID = role.ID AND user_role.DELETED = 0
    <where>
      role.DELETED = 0
      AND user_role.USER_ID = #{userId}
    </where>
  </select>
 
</mapper>