干燥机配套车间生产管理系统/云平台服务端
baoshiwei
2023-03-10 58d42ccf875b120f40fddce63752298e916e0b0b
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
<?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.SysTenantMapper">
 
    <!--获取租户回收站的数据假删除-->
    <select id="getRecycleBinPageList" resultType="org.jeecg.modules.system.entity.SysTenant">
        SELECT id,name,company_logo,house_number,status FROM sys_tenant
        WHERE
        del_flag = 1
        <if test="sysTenant.name!='' and sysTenant.name!=null">
            <bind name="name" value="'%'+sysTenant.name+'%'"/>
            AND name like #{name}
        </if>
        <if test="sysTenant.houseNumber!='' and sysTenant.houseNumber!=null">
            <bind name="houseNumber" value="'%'+sysTenant.houseNumber+'%'"/>
            AND house_number like #{houseNumber}
        </if>
    </select>
 
    <!--彻底删除租户信息-->
    <delete id="deleteByTenantId">
        DELETE FROM sys_tenant
        WHERE
        del_flag = 1
        AND id in
        <foreach collection="tenantIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
    <!--租户还原-->
    <update id="revertTenantLogic">
        UPDATE sys_tenant set del_flag = 0
        WHERE
        del_flag = 1
        AND id in
        <foreach collection="tenantIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
 
    <!-- 用于统计 租户产品包的人员数量 -->
    <select id="queryTenantPackUserCount" resultType="org.jeecg.modules.system.vo.tenant.TenantPackUserCount">
        SELECT pack_code, count(*) as user_count FROM sys_tenant_pack a 
        join sys_tenant_pack_user b on a.id = b.pack_id
        where a.tenant_id = #{tenantId} 
        and a.pack_code in ('superAdmin', 'accountAdmin', 'appAdmin')
        and b.status = 1
        group by a.pack_code
    </select>
 
    
    <!-- 查询人员的产品包编码 -->
    <select id="queryUserPackCode" resultType="java.lang.String">
        SELECT a.pack_code FROM sys_tenant_pack a 
        join sys_tenant_pack_user b on a.id = b.pack_id
        where a.tenant_id = #{tenantId} 
        and b.user_id = #{userId}
        and b.status = 1
    </select>
 
    <!-- 查询人员是不是租户产品包的 超级管理员 -->
    <select id="querySuperAdminCount" resultType="java.lang.Integer">
        SELECT count(*) FROM sys_tenant_pack a 
        join sys_tenant_pack_user b on a.id = b.pack_id
        where a.pack_code = 'superAdmin'
        and a.tenant_id = #{tenantId} 
        and b.user_id = #{userId}
        and b.status = 1
    </select>
 
    <!-- 查询产品包关联的用户列表 -->
    <select id="queryPackUserList" resultType="org.jeecg.modules.system.vo.tenant.TenantPackUser">
        SELECT c.id, c.username, c.realname, c.phone, c.avatar, a.pack_name, a.id as pack_id  FROM sys_user c
        join sys_tenant_pack_user b on c.id = b.user_id
        join sys_tenant_pack a on a.id = b.pack_id
        where c.status = 1 
        and c.del_flag = 0
        and b.status = #{packUserStatus}
        and a.tenant_id = #{tenantId}
        <if test="packId!='' and packId!=null">
            and a.id = #{packId}
        </if>
    </select>
 
 
    <!-- 根据用户ID 查询部门 -->
    <select id="queryUserDepartList" resultType="org.jeecg.modules.system.vo.tenant.UserDepart">
        SELECT c.id as user_id,a.depart_name  FROM sys_user c
        join sys_user_depart b on c.id = b.user_id
        join sys_depart a on a.id = b.dep_id
        where c.status = 1 and c.del_flag = 0
        and c.id in
        <foreach collection="userIdList" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <!-- 根据用户ID 查询职位 -->
    <select id="queryUserPositionList" resultType="org.jeecg.modules.system.vo.tenant.UserPosition">
        SELECT c.id as user_id, name as position_name FROM sys_user c
        join sys_user_position b on c.id = b.user_id
        join sys_position a on a.code = b.position_code
        where c.status = 1 and c.del_flag = 0
        and c.id in
        <foreach collection="userIdList" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    
</mapper>