干燥机配套车间生产管理系统/云平台服务端
bsw215583320
2024-04-16 c2fccb01b972176dc3da5a497b5e904025e9e98d
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
<?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="org.jeecg.modules.system.mapper.SysUserDepartMapper">
    <select id="getUserDepartByUid" parameterType="String" resultType="org.jeecg.modules.system.entity.SysUserDepart">
        SELECT *
        FROM sys_user_depart
        WHERE user_id = #{userId, jdbcType=VARCHAR}
    </select>
 
    <!-- 查询指定部门下的用户 并且支持用户账号模糊查询 -->
    <select id="queryDepartUserList" resultType="org.jeecg.modules.system.entity.SysUser">
        select a.* from sys_user a
        join sys_user_depart b on b.user_id = a.id
        join sys_depart c on b.dep_id = c.id
        <bind name="bindOrgCode" value="orgCode+'%'"/>
        where a.del_flag = 0 and c.org_code like #{bindOrgCode}
        <if test="realname!=null and realname!=''">
            <!-- update by sunjianlei 20220119【#3348】SQL injection exists in /sys/user/queryUserByDepId;  -->
            <bind name="bindRealname" value="'%'+realname+'%'"/>
            and a.realname like #{bindRealname}
        </if>
    </select>
 
    <!-- 根据部门查询部门用户 分页 -->
    <select id="queryDepartUserPageList" resultType="org.jeecg.modules.system.entity.SysUser">
        select a.*, c.depart_name as org_code_txt from sys_user a
        join sys_user_depart b on b.user_id = a.id
        join sys_depart c on b.dep_id = c.id
        <bind name="bindOrgCode" value="orgCode+'%'"/>
        where a.del_flag = 0 and a.status = 1 and c.org_code like #{bindOrgCode} and a.username!='_reserve_user_external'
        <if test="username!=null and username!=''">
            <bind name="bindUsername" value="'%'+username+'%'"/>
            and a.username like #{bindUsername}
        </if>
        <if test="realname!=null and realname!=''">
            <bind name="bindRealname" value="'%'+realname+'%'"/>
            and a.realname like #{bindRealname}
        </if>
    </select>
 
    <!--获取用户信息(聊天专用)-->
    <select id="getUserInformation" resultType="org.jeecg.modules.system.entity.SysUser">
        select DISTINCT a.* from sys_user a
        left join sys_user_depart b on b.user_id = a.id
        left join sys_depart c on b.dep_id = c.id
        <bind name="bindOrgCode" value="orgCode+'%'"/>
        where
          a.del_flag = 0 and a.status = 1
          and c.org_code like #{bindOrgCode}
          and a.username!='_reserve_user_external'
          and a.id !=#{userId}
        <if test="keyword!=null and keyword!=''">
            <bind name="bindKeyword" value="'%'+keyword+'%'"/>
            and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
        </if>
    </select>
 
    <!--获取用户信息(简版流程专用)-->
    <select id="getProcessUserList" resultType="org.jeecg.modules.system.entity.SysUser">
        select DISTINCT a.* from sys_user a
        left join sys_user_depart b on b.user_id = a.id
        left join sys_depart c on b.dep_id = c.id
        <bind name="bindOrgCode" value="orgCode+'%'"/>
        where
        a.del_flag = 0 and a.status = 1
        and c.org_code like #{bindOrgCode}
        and a.username!='_reserve_user_external'
        <if test="keyword!=null and keyword!=''">
            <bind name="bindKeyword" value="'%'+keyword+'%'"/>
            and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
        </if>
        <if test="tenantId!=null">
            and a.id in (
                select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
            )
        </if>
    </select>
    
    <!--获取租户下的部门-通过前台传过来的部门id-->
    <select id="getTenantDepart" resultType="java.lang.String">
        select id from sys_depart
        where
        id in
        <foreach collection="departIds" item="departId" open="(" close=")" separator="," >
            #{departId}
        </foreach>
        and tenant_id = #{tenantId}
    </select>
    
    <!--根据当前租户和用户id查询用户部门数据-->
    <select id="getTenantUserDepart" resultType="org.jeecg.modules.system.entity.SysUserDepart">
        select * from sys_user_depart
        where
        user_id = #{userId}
        and dep_id in(
            select id from sys_depart where tenant_id = #{tenantId}
        )
    </select>
    
    <!--根据用户id和租户id,删除用户部门数据-->
    <delete id="deleteUserDepart">
        delete from sys_user_depart
        where
        user_id = #{userId}
        and dep_id in(
            select id from sys_depart where tenant_id = #{tenantId}
        )
    </delete>
</mapper>