广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<?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">
<!-- 
 * @title: 客户用户表
 * @description: 自定义sql,请自行实现业务逻辑
 * @company: hugeinfo
 * @author: liyj
 * @time:2024-08-19 20:04:19
 * @version 1.0.0
-->
<mapper namespace="cn.huge.module.ctuser.dao.mapper.CtUserMapper">
    <!-- 结果集 -->
    <resultMap id="dataResult" type="cn.huge.module.ctuser.domain.po.CtUser">
            <result property="id" column="id"/>
            <result property="trueName" column="true_name"/>
            <result property="sex" column="sex"/>
            <result property="sexName" column="sex_name"/>
            <result property="mobile" column="mobile"/>
            <result property="idcard" column="idcard"/>
            <result property="email" column="email"/>
            <result property="wechat" column="wechat"/>
            <result property="qq" column="qq"/>
            <result property="prov" column="prov"/>
            <result property="provName" column="prov_name"/>
            <result property="city" column="city"/>
            <result property="cityName" column="city_name"/>
            <result property="area" column="area"/>
            <result property="areaName" column="area_name"/>
            <result property="road" column="road"/>
            <result property="roadName" column="road_name"/>
            <result property="village" column="village"/>
            <result property="villageName" column="village_name"/>
            <result property="addr" column="addr"/>
            <result property="avatar" column="avatar"/>
            <result property="unitId" column="unit_id"/>
            <result property="unitName" column="unit_name"/>
            <result property="deptId" column="dept_id"/>
            <result property="deptName" column="dept_name"/>
            <result property="joinWay" column="join_way"/>
            <result property="realStatus" column="real_status"/>
            <result property="status" column="status"/>
            <result property="goodField" column="good_field"/>
            <result property="goodFieldName" column="good_field_name"/>
            <result property="canField" column="can_field"/>
            <result property="canFieldName" column="can_field_name"/>
            <result property="findStatus" column="find_status"/>
            <result property="dispStatus" column="disp_status"/>
            <result property="deleteStatus" column="delete_status"/>
            <result property="custId" column="cust_id"/>
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dyh_ct_user</sql>
    <!-- 字段 -->
    <sql id="column-part">
        id,
        true_name,
        sex,
        sex_name,
        mobile,
        idcard,
        email,
        wechat,
        qq,
        prov,
        prov_name,
        city,
        city_name,
        area,
        area_name,
        road,
        road_name,
        village,
        village_name,
        addr,
        avatar,
        unit_id,
        unit_name,
        dept_id,
        dept_name,
        join_way,
        real_status,
        status,
        good_field,
        good_field_name,
        can_field,
        can_field_name,
        find_status,
        disp_status,
        delete_status,
        cust_id,
        create_time,
        update_time
    </sql>
    <!-- 更新实体字段 -->
    <sql id="set-part">
            <if test="entity.trueName != null">true_name = #{entity.trueName},</if>
            <if test="entity.sex != null">sex = #{entity.sex},</if>
            <if test="entity.sexName != null">sex_name = #{entity.sexName},</if>
            <if test="entity.mobile != null">mobile = #{entity.mobile},</if>
            <if test="entity.idcard != null">idcard = #{entity.idcard},</if>
            <if test="entity.email != null">email = #{entity.email},</if>
            <if test="entity.wechat != null">wechat = #{entity.wechat},</if>
            <if test="entity.qq != null">qq = #{entity.qq},</if>
            <if test="entity.prov != null">prov = #{entity.prov},</if>
            <if test="entity.provName != null">prov_name = #{entity.provName},</if>
            <if test="entity.city != null">city = #{entity.city},</if>
            <if test="entity.cityName != null">city_name = #{entity.cityName},</if>
            <if test="entity.area != null">area = #{entity.area},</if>
            <if test="entity.areaName != null">area_name = #{entity.areaName},</if>
            <if test="entity.road != null">road = #{entity.road},</if>
            <if test="entity.roadName != null">road_name = #{entity.roadName},</if>
            <if test="entity.village != null">village = #{entity.village},</if>
            <if test="entity.villageName != null">village_name = #{entity.villageName},</if>
            <if test="entity.addr != null">addr = #{entity.addr},</if>
            <if test="entity.avatar != null">avatar = #{entity.avatar},</if>
            <if test="entity.unitId != null">unit_id = #{entity.unitId},</if>
            <if test="entity.unitName != null">unit_name = #{entity.unitName},</if>
            <if test="entity.deptId != null">dept_id = #{entity.deptId},</if>
            <if test="entity.deptName != null">dept_name = #{entity.deptName},</if>
            <if test="entity.joinWay != null">join_way = #{entity.joinWay},</if>
            <if test="entity.realStatus != null">real_status = #{entity.realStatus},</if>
            <if test="entity.status != null">status = #{entity.status},</if>
            <if test="entity.goodField != null">good_field = #{entity.goodField},</if>
            <if test="entity.goodFieldName != null">good_field_name = #{entity.goodFieldName},</if>
            <if test="entity.canField != null">can_field = #{entity.canField},</if>
            <if test="entity.canFieldName != null">can_field_name = #{entity.canFieldName},</if>
            <if test="entity.findStatus != null">find_status = #{entity.findStatus},</if>
            <if test="entity.dispStatus != null">disp_status = #{entity.dispStatus},</if>
            <if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus},</if>
            <if test="entity.custId != null">cust_id = #{entity.custId},</if>
            <if test="entity.createTime != null">create_time = #{entity.createTime},</if>
            <if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part">
        <if test="terms != null">
            <where>
                <if test="terms.id != null and terms.id !=''">
                    and id = #{terms.id}
                </if>
                <if test="terms.trueName != null and terms.trueName !=''">
                    and true_name = #{terms.trueName}
                </if>
                <if test="terms.sex != null and terms.sex !=''">
                    and sex = #{terms.sex}
                </if>
                <if test="terms.sexName != null and terms.sexName !=''">
                    and sex_name = #{terms.sexName}
                </if>
                <if test="terms.mobile != null and terms.mobile !=''">
                    and mobile = #{terms.mobile}
                </if>
                <if test="terms.idcard != null and terms.idcard !=''">
                    and idcard = #{terms.idcard}
                </if>
                <if test="terms.email != null and terms.email !=''">
                    and email = #{terms.email}
                </if>
                <if test="terms.wechat != null and terms.wechat !=''">
                    and wechat = #{terms.wechat}
                </if>
                <if test="terms.qq != null and terms.qq !=''">
                    and qq = #{terms.qq}
                </if>
                <if test="terms.prov != null and terms.prov !=''">
                    and prov = #{terms.prov}
                </if>
                <if test="terms.provName != null and terms.provName !=''">
                    and prov_name = #{terms.provName}
                </if>
                <if test="terms.city != null and terms.city !=''">
                    and city = #{terms.city}
                </if>
                <if test="terms.cityName != null and terms.cityName !=''">
                    and city_name = #{terms.cityName}
                </if>
                <if test="terms.area != null and terms.area !=''">
                    and area = #{terms.area}
                </if>
                <if test="terms.areaName != null and terms.areaName !=''">
                    and area_name = #{terms.areaName}
                </if>
                <if test="terms.road != null and terms.road !=''">
                    and road = #{terms.road}
                </if>
                <if test="terms.roadName != null and terms.roadName !=''">
                    and road_name = #{terms.roadName}
                </if>
                <if test="terms.village != null and terms.village !=''">
                    and village = #{terms.village}
                </if>
                <if test="terms.villageName != null and terms.villageName !=''">
                    and village_name = #{terms.villageName}
                </if>
                <if test="terms.addr != null and terms.addr !=''">
                    and addr = #{terms.addr}
                </if>
                <if test="terms.avatar != null and terms.avatar !=''">
                    and avatar = #{terms.avatar}
                </if>
                <if test="terms.unitId != null and terms.unitId !=''">
                    and unit_id = #{terms.unitId}
                </if>
                <if test="terms.unitName != null and terms.unitName !=''">
                    and unit_name = #{terms.unitName}
                </if>
                <if test="terms.deptId != null and terms.deptId !=''">
                    and dept_id = #{terms.deptId}
                </if>
                <if test="terms.deptName != null and terms.deptName !=''">
                    and dept_name = #{terms.deptName}
                </if>
                <if test="terms.joinWay != null and terms.joinWay !=''">
                    and join_way = #{terms.joinWay}
                </if>
                <if test="terms.realStatus != null and terms.realStatus !=''">
                    and real_status = #{terms.realStatus}
                </if>
                <if test="terms.status != null and terms.status !=''">
                    and status = #{terms.status}
                </if>
                <if test="terms.goodField != null and terms.goodField !=''">
                    and good_field = #{terms.goodField}
                </if>
                <if test="terms.goodFieldName != null and terms.goodFieldName !=''">
                    and good_field_name = #{terms.goodFieldName}
                </if>
                <if test="terms.canField != null and terms.canField !=''">
                    and can_field = #{terms.canField}
                </if>
                <if test="terms.canFieldName != null and terms.canFieldName !=''">
                    and can_field_name = #{terms.canFieldName}
                </if>
                <if test="terms.findStatus != null and terms.findStatus !=''">
                    and find_status = #{terms.findStatus}
                </if>
                <if test="terms.dispStatus != null and terms.dispStatus !=''">
                    and disp_status = #{terms.dispStatus}
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and delete_status = #{terms.deleteStatus}
                </if>
                <if test="terms.custId != null and terms.custId !=''">
                    and cust_id = #{terms.custId}
                </if>
                <if test="terms.createTime != null and terms.createTime !=''">
                    and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
                </if>
                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
                    and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
                        and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
                </if>
                <if test="terms.updateTime != null and terms.updateTime !=''">
                    and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
                </if>
                <if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
                    and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
                        and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
                </if>
            </where>
        </if>
    </sql>
    <!-- 更新对象 -->
    <update id="updateCtUser">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <where>
            id = #{entity.id}
        </where>
    </update>
    <!-- 条件更新对象 -->
    <update id="updateCtUserTerms">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <include refid="where-part"/>
    </update>
    <!--  根据编号物理删除  -->
    <delete id="deleteCtUser">
        delete from
        <include refid="table-name" />
        where id = #{id}
    </delete>
    <!--  根据条件查询  -->
    <select id="listTerms" resultMap="dataResult">
        select
        <include refid="column-part"/>
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件统计  -->
    <select id="countTerms" resultType="java.lang.Long">
        select
        COUNT(1)
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件分页查询  -->
    <select id="pageTerms" resultMap="dataResult">
        SELECT
        <include refid="column-part"/>
        FROM
        <include refid="table-name" />
        <include refid="where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(create_time), create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
    <!--  根据条件统计  -->
    <select id="countQueryCtUser" resultType="java.lang.Long">
        SELECT COUNT(distinct t1.id)
        FROM dyh_ct_user t1
        LEFT JOIN dyh_ct_userole t2 on t1.id = t2.user_id
        <if test="terms != null">
            <where>
                <if test="terms.trueName != null and terms.trueName !=''">
                    and t1.true_name like concat('%', #{terms.trueName}, '%')
                </if>
                <if test="terms.acc != null and terms.acc !=''">
                    and t1.acc like concat('%', #{terms.acc}, '%')
                </if>
                <if test="terms.unitId != null and terms.unitId !=''">
                    and t1.unit_id = #{terms.unitId}
                </if>
                <if test="terms.deptId != null and terms.deptId !=''">
                    and t1.dept_id = #{terms.deptId}
                </if>
                <if test="terms.status != null and terms.status !=''">
                    and t1.status = #{terms.status}
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and t1.delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and t1.delete_status = #{terms.deleteStatus}
                </if>
                <if test="terms.roleId != null and terms.roleId !=''">
                    and t2.role_id = #{terms.roleId}
                </if>
            </where>
        </if>
    </select>
 
    <!--  根据条件分页查询  -->
    <select id="pageQueryCtUser" resultMap="dataResult">
        SELECT t1.*
        FROM dyh_ct_user t1
        LEFT JOIN dyh_ct_userole t2 on t1.id = t2.user_id
        <if test="terms != null">
            <where>
                <if test="terms.trueName != null and terms.trueName !=''">
                    and t1.true_name like concat('%', #{terms.trueName}, '%')
                </if>
                <if test="terms.acc != null and terms.acc !=''">
                    and t1.acc like concat('%', #{terms.acc}, '%')
                </if>
                <if test="terms.unitId != null and terms.unitId !=''">
                    and t1.unit_id = #{terms.unitId}
                </if>
                <if test="terms.deptId != null and terms.deptId !=''">
                    and t1.dept_id = #{terms.deptId}
                </if>
                <if test="terms.status != null and terms.status !=''">
                    and t1.status = #{terms.status}
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and t1.delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and t1.delete_status = #{terms.deleteStatus}
                </if>
                <if test="terms.roleId != null and terms.roleId !=''">
                    and t2.role_id = #{terms.roleId}
                </if>
                <if test="terms.roleCode != null and terms.roleCode !=''">
                    and t2.role_code = #{terms.roleCode}
                </if>
            </where>
        </if>
        GROUP BY t1.id
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
    <!--  根据部门和角色查询  -->
    <select id="listUserByUnitRoleList" resultMap="dataResult">
        SELECT t1.id, t1.true_name, t1.dept_id,t1.dept_name
        FROM dyh_ct_user t1 LEFT JOIN dyh_ct_userole t2 ON t1.id = t2.user_id
        WHERE
        t1.delete_status = '0'
        AND t2.role_code = #{roleCode}
        AND t1.status = '1'
        AND t1.unit_id = #{unitId}
    </select>
 
    <select id="selectByIdCard" resultMap="dataResult">
        SELECT * FROM dyh_ct_user
        WHERE
            delete_status = '0'
            and status = '1' and idcard=#{idCard}
    </select>
</mapper>