wang-hao-jie
2022-08-25 57dcc73636bb7d8dce89c808eb8cc988a7512264
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?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.ruoyi.station.mapper.MjWorkUserMapper">
    
    <resultMap type="MjWorkUser" id="MjWorkUserResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="organizationId"    column="organization_id"    />
        <result property="organizationName"    column="organization_name"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="pass"    column="pass"    />
        <result property="enable"    column="enable"    />
        <result property="iPrivilege"    column="iPrivilege"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="sort"    column="sort"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="expandStatus"    column="expand_status"    />
        <result property="expandStatus1"    column="expand_status1"    />
    </resultMap>
 
    <sql id="selectMjWorkUserVo">
        select id, user_id, user_name, organization_id, organization_name, dept_id, dept_name, pass,enable,iPrivilege, create_time, update_time, create_by, update_by, sort, del_flag, expand_status, expand_status1 from mj_work_user
    </sql>
 
    <select id="selectMjWorkUserList" parameterType="MjWorkUser" resultMap="MjWorkUserResult">
        SELECT u.*
        from mj_work_user u
        left JOIN mj_dept d on u.dept_id=d.id
        where u.del_flag='0'
            <if test="userId != null  and userId != ''"> and u.user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
            <if test="organizationId != null  and organizationId != ''"> and u.organization_id = #{organizationId}</if>
            <if test="organizationName != null  and organizationName != ''"> and u.organization_name like concat('%', #{organizationName}, '%')</if>
            <if test="deptId != null  and deptId != ''"> and u.dept_id =#{deptId} OR u.`dept_id` IN( SELECT t.id FROM mj_dept t WHERE FIND_IN_SET(#{deptId},t.dept_parent_id))  </if>
            <if test="deptName != null  and deptName != ''"> and u.dept_name like concat('%', #{deptName}, '%')</if>
            <if test="pass != null  and pass != ''"> and u.pass = #{pass}</if>
            <if test="enable != null  and enable != ''"> and u.enable = #{enable}</if>
            <if test="iPrivilege != null  and iPrivilege != ''"> and u.iPrivilege = #{iPrivilege}</if>
            <if test="sort != null "> and u.sort = #{sort}</if>
            <if test="expandStatus != null "> and u.expand_status = #{expandStatus}</if>
            <if test="expandStatus1 != null "> and u.expand_status1 = #{expandStatus1}</if>
        order by create_time desc
    </select>
    
    <select id="selectMjWorkUserById" parameterType="Long" resultMap="MjWorkUserResult">
        <include refid="selectMjWorkUserVo"/>
        where id = #{id}
    </select>
    <select id="selectMjWorkUserListAll" parameterType="MjWorkUser" resultMap="MjWorkUserResult">
        SELECT *
        from mj_work_user
        <where>
            del_flag='0'
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="organizationId != null  and organizationId != ''"> and organization_id = #{organizationId}</if>
            <if test="organizationName != null  and organizationName != ''"> and organization_name like concat('%', #{organizationName}, '%')</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="pass != null  and pass != ''"> and pass = #{pass}</if>
            <if test="enable != null  and enable != ''"> and enable = #{enable}</if>
            <if test="iPrivilege != null  and iPrivilege != ''"> and iPrivilege = #{iPrivilege}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="expandStatus != null "> and expand_status = #{expandStatus}</if>
            <if test="expandStatus1 != null "> and expand_status1 = #{expandStatus1}</if>
        </where>
    </select>
    <select id="selectUserByLoginName" parameterType="String" resultMap="MjWorkUserResult">
        <include refid="selectMjWorkUserVo"/>
        where user_name = #{userName}
    </select>
 
    <insert id="insertMjWorkUser" parameterType="MjWorkUser" useGeneratedKeys="true" keyProperty="id">
        insert into mj_work_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="organizationId != null">organization_id,</if>
            <if test="organizationName != null">organization_name,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="pass != null">pass,</if>
            <if test="enable != null">enable,</if>
            <if test="iPrivilege != null">iPrivilege,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="sort != null">sort,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="expandStatus != null">expand_status,</if>
            <if test="expandStatus1 != null">expand_status1,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="organizationId != null">#{organizationId},</if>
            <if test="organizationName != null">#{organizationName},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="pass != null">#{pass},</if>
            <if test="enable != null">#{enable},</if>
            <if test="iPrivilege != null">#{iPrivilege},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="sort != null">#{sort},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="expandStatus != null">#{expandStatus},</if>
            <if test="expandStatus1 != null">#{expandStatus1},</if>
         </trim>
    </insert>
 
    <update id="updateMjWorkUser" parameterType="MjWorkUser">
        update mj_work_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="organizationId != null">organization_id = #{organizationId},</if>
            <if test="organizationName != null">organization_name = #{organizationName},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="pass != null">pass = #{pass},</if>
            <if test="enable != null">enable = #{enable},</if>
            <if test="iPrivilege != null">iPrivilege = #{iPrivilege},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="expandStatus != null">expand_status = #{expandStatus},</if>
            <if test="expandStatus1 != null">expand_status1 = #{expandStatus1},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteMjWorkUserById" parameterType="Long">
        delete from mj_work_user where id = #{id}
    </delete>
 
    <delete id="deleteMjWorkUserByIds" parameterType="String">
        delete from mj_work_user where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectWorkUserCount" resultType="Integer">
        select count(1) from mj_work_user where del_flag = 0
    </select>
 
    <select id="selectUserListByDeptId" parameterType="String" resultType="com.ruoyi.station.model.DeptUsersModel">
        select id id, user_name title from mj_work_user
        where
        del_flag='0'
        <if test="deptId != null  and deptId != ''"> and dept_id =#{deptId}</if>
    </select>
 
    <select id="selectWorkUserCountById" parameterType="Long" resultType="Integer">
        select count(1) from mj_work_user where id = #{id}
    </select>
 
    <select id="selectUserNamesByTogetherUserIds" parameterType="String" resultType="String">
        select user_name from mj_work_user
        where id in
        <foreach item="id" collection="togetherUserIds" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <select id="getUserName" resultType="java.lang.String">
        select user_name from mj_work_user where id = #{userId}
    </select>
 
    <select id="getUserNames" resultType="java.lang.String">
        select user_name from mj_work_user
        where id in
        <foreach item="id" collection="userIds" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <select id="selectNewUser" parameterType="String" resultMap="MjWorkUserResult">
        <include refid="selectMjWorkUserVo"/>
        where expand_status = 1
    </select>
</mapper>