| <?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 '%'||#{dto.code}||'%' | 
|       </if> | 
|       <if test="dto.name != null and dto.name != ''"> | 
|         AND role.name LIKE '%'||#{dto.name}||'%' | 
|       </if> | 
|     </where> | 
|     ${orderByClause} | 
|   </select> | 
|   | 
|   <!-- 查询用户角色列表 --> | 
|   <select id="selectByUserId" 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.deleted = 0 | 
|       and user_role.user_id = #{userId} | 
|     </where> | 
|   </select> | 
|   | 
| </mapper> |