#
vincentlu
2025-02-13 877722e08ae42cddc4048578561b8e8999523e0d
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
<?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.vincent.rsf.server.system.mapper.UserMapper">
 
    <select id="selectPageRel" resultType="com.vincent.rsf.server.system.entity.User">
        select
        DISTINCT su.*
        from sys_user su
        left join sys_dept sd on su.dept_id = sd.id
        left join sys_user_role sur on sur.user_id = su.id
        where 1=1
        and su.deleted = 0
 
        <if test="param.deptId != null">
            and (FIND_IN_SET(#{param.deptId}, sd.`path`) OR sd.`id` = #{param.deptId})
        </if>
 
        <if test="param.roleIds != null and param.roleIds.size > 0">
            and sur.role_id in
            <foreach collection="param.roleIds" item="item" index="idx"  separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
 
        <if test="param.username != null">
            and su.username like concat('%',#{param.username},'%')
        </if>
        <if test="param.nickname != null">
            and su.nickname like concat('%',#{param.nickname},'%')
        </if>
        <if test="param.code != null">
            and su.code like concat('%',#{param.code},'%')
        </if>
        <if test="param.phone != null">
            and su.phone like concat('%',#{param.phone},'%')
        </if>
        <if test="param.email != null">
            and su.email like concat('%',#{param.email},'%')
        </if>
        <if test="param.sex != null">
            and su.sex = #{param.sex}
        </if>
        <if test="param.status != null">
            and su.status = #{param.status}
        </if>
        <if test="param.realName != null">
            and su.real_name like concat('%',#{param.realName},'%')
        </if>
        <if test="param.idCard != null">
            and su.id_card like concat('%',#{param.idCard},'%')
        </if>
        <if test="param.memo != null">
            and su.memo = like concat('%',#{param.memo},'%')
        </if>
        <if test="param.condition != null">
            and (
                   su.username like concat('%',#{param.condition},'%')
                or su.nickname like concat('%',#{param.condition},'%')
                or su.phone like concat('%',#{param.condition},'%')
                or su.code like concat('%',#{param.condition},'%')
                or su.email like concat('%',#{param.condition},'%')
                or su.real_name like concat('%',#{param.condition},'%')
                or su.id_card like concat('%',#{param.condition},'%')
            )
        </if>
        <if test="param.timeStart != null">
            and su.create_time >= #{param.timeStart}
        </if>
        <if test="param.timeEnd != null">
            and su.create_time &lt; #{param.timeEnd}
        </if>
        <if test="param.orderBy != null and param.orderBy != '' ">
            order by su.${param.orderBy}
        </if>
    </select>
 
    <select id="selectByUsernameWithoutTenant" resultType="com.vincent.rsf.server.system.entity.User">
        select * from sys_user
        where 1=1
        and deleted = 0
        and username = #{username}
        <if test="tenantId != null">
            AND tenant_id = #{tenantId}
        </if>
    </select>
 
    <select id="selectByEmailWithoutTenant" resultType="com.vincent.rsf.server.system.entity.User">
        select * from sys_user
        where 1=1
        and deleted = 0
        and email = #{email}
        <if test="tenantId != null">
            AND tenant_id = #{tenantId}
        </if>
    </select>
 
</mapper>