jiangping
2023-09-27 54a32ffec350618ddb98fd430a9eecc2f395f958
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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.admin_type,usr.user_type,usr.nickname,usr.accepted_number,usr.total_integral,usr.type,
    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
    <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>
 
    </where>
    order by usr.accepted_number desc
  </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>