| <?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.SystemUserMapper"> | 
|   | 
|   <!-- 查询用户列表 --> | 
|   <resultMap id="SystemUserListVO" type="com.doumee.dao.system.vo.SystemUserListVO" autoMapping="true"> | 
|     <id column="id" property="id"/> | 
|     <association property="department" javaType="com.doumee.dao.system.model.SystemDepartment"> | 
|       <result column="department_id" property="id"/> | 
|       <result column="department_name" property="name"/> | 
|     </association> | 
|     <association property="createUserInfo" javaType="com.doumee.dao.system.model.SystemUser"> | 
|       <result column="create_user_id" property="id"/> | 
|       <result column="create_user_name" property="username"/> | 
|     </association> | 
|     <association property="updateUserInfo" javaType="com.doumee.dao.system.model.SystemUser"> | 
|       <result 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="SystemUserListVO"> | 
|     select | 
|     distinct | 
|     usr.id, usr.birthday, usr.email, usr.emp_no, usr.mobile, usr.avatar, usr.username, usr.realname, usr.sex, usr.fixed, usr.create_time, usr.update_time, | 
|     sd.id as department_id, sd.name as department_name, | 
|     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_user" usr | 
|     left join "system_user" create_user on create_user.id = usr.create_user | 
|     left join "system_user" update_user on update_user.id = usr.update_user | 
|     left join system_position_user spu on spu.user_id = usr.id and spu.deleted = 0 | 
|     left join system_position sp on sp.id = spu.position_id and sp.deleted = 0 | 
|     left join system_department_user sdu on sdu.user_id = usr.id and sdu.deleted = 0 | 
|     left join system_department sd on sd.id = sdu.department_id and sd.deleted = 0 | 
|     <where> | 
|       usr.deleted = 0 | 
|       <if test="dto.positionId != null"> | 
|         AND spu.position_id = #{dto.positionId} | 
|       </if> | 
|       <if test="dto.strictDeptId != null"> | 
|         AND sdu.department_id = #{dto.strictDeptId} | 
|       </if> | 
|       <if test="dto.departmentIds != null and dto.departmentIds.size > 0"> | 
|         AND sdu.department_id IN | 
|         <foreach collection="dto.departmentIds" open="(" close=")" separator="," item="id"> | 
|           #{id} | 
|         </foreach> | 
|       </if> | 
|       <if test="dto.username != null and dto.username != ''"> | 
|         AND usr.username LIKE '%'||#{dto.username}||'%' | 
|       </if> | 
|       <if test="dto.realname != null and dto.realname != ''"> | 
|         AND usr.realname LIKE '%'||#{dto.realname}||'%' | 
|       </if> | 
|       <if test="dto.mobile != null and dto.mobile != ''"> | 
|         AND usr.mobile  LIKE '%'||#{dto.mobile}||'%' | 
|       </if> | 
|     </where> | 
|     ${orderByClause} | 
|   </select> | 
|   | 
|   <select id="selectManageListNew" parameterType="com.doumee.dao.system.dto.QuerySystemUserDTO" resultMap="SystemUserListVO"> | 
|     select | 
|     distinct | 
|     usr.id, usr.birthday, usr.email, usr.emp_no, usr.mobile, usr.avatar, usr.username, usr.realname, usr.sex, usr.fixed, usr.create_time, usr.update_time, | 
|     usr.nickname,usr.status, | 
|     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_user" usr | 
|     left join "system_user" create_user on create_user.id = usr.create_user | 
|     left join "system_user" update_user on update_user.id = usr.update_user | 
|     left join "system_user_role" sur on sur.user_id = usr.id | 
|     <where> | 
|       usr.deleted = 0 | 
|       <if test="dto.username != null and dto.username != ''"> | 
|         AND usr.username LIKE '%'||#{dto.username}||'%' | 
|       </if> | 
|       <if test="dto.realname != null and dto.realname != ''"> | 
|         AND usr.realname LIKE '%'||#{dto.realname}||'%' | 
|       </if> | 
|       <if test="dto.mobile != null and dto.mobile != ''"> | 
|         AND usr.mobile  LIKE '%'||#{dto.mobile}||'%' | 
|       </if> | 
|       <if test="dto.status != null "> | 
|         AND usr.status  = #{dto.status} | 
|       </if> | 
|       <if test="dto.roleId != null and dto.roleId != ''"> | 
|         AND sur.role_id  = #{dto.roleId} | 
|       </if> | 
|   | 
|     </where> | 
|   </select> | 
|   | 
|   | 
|   | 
|   <select id="selectListNew" parameterType="com.doumee.dao.system.model.SystemUser" resultMap="SystemUserListVO"> | 
|     select "u".* from "system_user" "u" | 
|     <where> | 
|       <if test="username != null and username != '' "> | 
|         AND "u".username like '%'||#{username}||'%' | 
|       </if> | 
|     </where> | 
|     order by "u"."create_time" desc | 
|   </select> | 
|   | 
|   <update id="updateLoginDate" parameterType="com.doumee.dao.system.model.SystemUser" > | 
|     update "system_user"  set last_login=#{lastLogin} where id=#{id} | 
|   </update> | 
|   <update id="updateBySelective" parameterType="com.doumee.dao.system.model.SystemUser" > | 
|     update "system_user" | 
|     <set> | 
|       <if test="username != null"> | 
|         username = #{username}, | 
|       </if> | 
|       <if test="realname != null"> | 
|         realname = #{realname}, | 
|       </if> | 
|       <if test="empNo != null"> | 
|         emp_no = #{empNo}, | 
|       </if> | 
|       <if test="birthday != null"> | 
|         birthday = #{birthday}, | 
|       </if> | 
|       <if test="sex != null"> | 
|         sex = #{sex}, | 
|       </if> | 
|       <if test="email != null"> | 
|         email = #{email}, | 
|       </if> | 
|       <if test="mobile != null"> | 
|         mobile = #{mobile}, | 
|       </if> | 
|       <if test="avatar != null"> | 
|         avatar = #{avatar}, | 
|       </if> | 
|       <if test="password != null"> | 
|         password = #{password}, | 
|       </if> | 
|       <if test="salt != null"> | 
|         salt = #{salt}, | 
|       </if> | 
|       <if test="fixed != null"> | 
|         fixed = #{fixed}, | 
|       </if> | 
|       <if test="createUser != null"> | 
|         create_user = #{createUser}, | 
|       </if> | 
|       <if test="createTime != null"> | 
|         create_time = #{createTime}, | 
|       </if> | 
|       <if test="updateUser != null"> | 
|         update_user = #{updateUser}, | 
|       </if> | 
|       <if test="updateTime != null"> | 
|         update_time = #{updateTime}, | 
|       </if> | 
|       <if test="deleted != null"> | 
|         deleted = #{deleted}, | 
|       </if> | 
|       <if test="nickname != null"> | 
|         nickname = #{nickname}, | 
|       </if> | 
|         <if test="remark != null"> | 
|         remark = #{remark}, | 
|       </if> | 
|       <if test="status != null"> | 
|         status = #{status}, | 
|       </if> | 
|     </set> | 
|     where id=#{id} | 
|   </update> | 
|   | 
| </mapper> |