邱宇豪
2023-11-03 bd74616204baf4e3f8bb124f142a07be8e5e9f13
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
<?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.thhy.mobile.modules.biz.login.mapper.SysUserMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        user_id as userId,
        username as username,
        password as password,
        real_name as realName,
        telphone as telphone,
        photo_url as photoUrl,
        create_user as createUser,
        create_time as createTime,
        is_use as isUse,
        sex as sex,
        email as email,
        version as version,
            sub_admin as subAdmin
    </sql>
 
    <!-- 排除密码列 -->
    <sql id="Without_Pass_Column_List">
        user_id as userId,
        username as username,
        real_name as realName,
        telphone as telphone,
        photo_url as photoUrl,
        create_user as createUser,
        create_time as createTime,
        is_use as isUse,
        sex as sex,
        email as email,
        version as version
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND " >
                is_use = 1 AND
                <if test="username!=null and username!=''">
                    username LIKE  concat('%',#{username},'%') AND
                </if>
                <if test="realName!=null and realName!=''">
                    real_name = #{realName} AND
                </if>
                <if test="telphone!=null and telphone!=''">
                    telphone LIKE concat('%',#{telphone},'%') AND
                </if>
                <if test="createTime!=null">
                    create_time = #{createTime} AND
                </if>
                <!--<if test="isUse!=null">
                    is_use = #{isUse} AND
                </if>-->
                <if test="sex!=null">
                    sex = #{sex} AND
                </if>
                <if test="email!=null and email!=''">
                    email = #{email} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryByUsername" resultType="com.thhy.mobile.modules.biz.login.entity.SysUsers">
        SELECT
            su.user_id as userId,
            su.username as username,
            su.real_name as realName,
            su.password,
            su.telphone as telphone,
            su.photo_url as photoUrl,
            su.create_user as createUser,
            su.create_time as createTime,
            su.is_use as isUse,
            su.sex as sex,
            su.email as email,
            su.sub_admin as subAdmin,
            su.is_plat as isPlat
        FROM sys_users su
        WHERE (su.username = #{username} OR su.email = #{username} OR su.telphone = #{username})
          AND su.is_use = 1 and su.is_app = 1
    </select>
 
    <select id="queryCompanyByComAdmin" resultType="hashmap">
        select sc.company_id as companyId,sc.company_name as companyName
        from sys_com_su scs
                 left join sys_company sc on sc.company_id = scs.company_id
        where scs.user_id = #{userId}
    </select>
 
    <select id="queryCompanyByUser" resultType="hashmap">
        select sc.company_id as companyId,sc.company_name as companyName from sys_users su
         left join sys_plat_user spu on spu.user_id = su.plat_id
         left join sys_depart_user sdu on sdu.user_id = spu.user_id
         left join sys_com_depart scd on scd.depart_id = sdu.depart_id
         left join sys_company sc on sc.company_id = scd.company_id
        where su.user_id = #{userId} and su.is_use = 1
    </select>
</mapper>