jiangping
2025-06-26 0d2a03ec404b9c047d5d5cd4654a48882135be5f
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
84
85
86
87
88
<?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"/>
      <result column="CREATE_REAL_NAME" property="realname"/>
    </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"/>
      <result column="UPDATE_REAL_NAME" property="realname"/>
    </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,usr.wechat_name,usr.status,usr.OPENID,usr.type,
      create_user.ID CREATE_USER_ID, create_user.`USERNAME` CREATE_USER_NAME, create_user.`REALNAME` CREATE_REAL_NAME,
      update_user.ID UPDETE_USER_ID, update_user.`USERNAME` UPDATE_USER_NAME, create_user.`REALNAME` UPDATE_REAL_NAME,
      sd.company_name_path as companyName
    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 `company` sd ON sd.ID = usr.COMPANY_ID AND sd.ISDELETED = 0
    LEFT JOIN `member` m ON usr.MEMBER_ID = m.id
    <if test="dto.roleId != null">
      RIGHT JOIN system_user_role sur on sur.USER_ID = usr.ID and sur.DELETED = 0  and sur.ROLE_ID = #{dto.roleId}
    </if>
    <where>
      usr.DELETED = 0
      and usr.SOURCE = 0
<!--      <if test="dto.positionId != null">-->
<!--        AND spu.POSITION_ID = #{dto.positionId}-->
<!--      </if>-->
      <if test="dto.strictDeptId != null">
        AND  sd.ID = #{dto.strictDeptId}
      </if>
      <if test="dto.departmentIds != null and dto.departmentIds.size > 0">
        AND sd.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 CONCAT('%', #{dto.username}, '%')
      </if>
      <if test="dto.realname != null and dto.realname != ''">
        AND usr.`REALNAME` LIKE CONCAT('%', #{dto.realname}, '%')
      </if>
      <if test="dto.mobile != null and dto.mobile != ''">
        AND usr.`MOBILE` LIKE CONCAT('%', #{dto.mobile}, '%')
      </if>
      <if test="dto.companyName != null and dto.companyName != ''">
        AND sd.`company_name_path` LIKE CONCAT('%', #{dto.companyName}, '%')
      </if>
      <if test="dto.status != null ">
        AND  usr.`status` = #{dto.status}
      </if>
      <if test="dto.memberType != null ">
        AND  usr.`type` = #{dto.memberType}
      </if>
      <if test="dto.workStatus != null ">
        AND  m.WORK_STATUS = #{dto.workStatus}
      </if>
      <if test="dto.companyId != null ">
        AND  usr.COMPANY_ID  = #{dto.companyId}
      </if>
      <if test="dto.companyType != null ">
        AND  sd.`type` = #{dto.companyType}
      </if>
      <if test="dto.querySpecial != null and dto.querySpecial == 1 ">
            AND find_in_set(#{dto.companySpecialId},REPLACE(sd.company_path,'/',','))
      </if>
    </where>
    ${orderByClause}
  </select>
 
</mapper>