lyh
2025-01-16 700ac5685214d37f128b3ad3dfda59e80381b9f6
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.dnc.mapper.DeviceGroupMapper">
    <resultMap id="deviceGroupExtBaseResult" type="org.jeecg.modules.dnc.dto.DeviceGroupExt">
        <id column="group_id"  property="groupId" />
        <collection column="group_id" property="children" select="findByParentId">
        </collection>
    </resultMap>
    <select id="findExtAll" resultMap="deviceGroupExtBaseResult">
        select group_id
        , group_name
        , parent_id
        , rank_level
        , description
        from nc_device_group where rank_level=1 and delete_flag=0
    </select>
    <select id="findExtByDeparts" resultMap="deviceGroupExtBaseResult" parameterType="List">
        select dg.group_id
        , dg.group_name
        , dg.parent_id
        , dg.rank_level
        , dg.description
        from (select * from nc_device_group where rank_level=1 and delete_flag=0) dg
        inner join nc_device_group_department dep
        on dg.group_id=dep.group_id
        where dep.depart_id in
        <foreach collection="departIds" item="departId" index="index" open="(" close=")" separator=",">
            #{departId}
        </foreach>
    </select>
 
    <select id="findByParentId" resultMap="deviceGroupExtBaseResult" parameterType="String">
        select group_id
        , group_name
        , parent_id
        , rank_level
        , description
        from nc_device_group
        where parent_id=#{parentId} and delete_flag=0
    </select>
 
    <resultMap id="deviceGroupExtPermsMap" type="org.jeecg.modules.dnc.dto.DeviceGroupExt">
        <id column="group_id"  property="groupId" />
        <result column="user_id" property="userId" />
        <collection column="{parentId=group_id, userId=user_id}" property="children"
                    javaType="ArrayList" ofType="org.jeecg.modules.dnc.dto.DeviceGroupExt" select="getByParentIdAndUserPerms">
            <id column="group_id"  property="groupId" />
            <result column="user_id" property="userId" />
        </collection>
    </resultMap>
 
    <resultMap id="deviceGroupExtPermsMapAs" type="org.jeecg.modules.dnc.dto.DeviceGroupExt">
        <id column="group_id"  property="groupId" />
        <association property="parent" column="{id=parent_id}" select="findById">
        </association>
    </resultMap>
 
    <select id="getByUserPerms" resultMap="deviceGroupExtPermsMap" parameterType="String">
       select comp.group_id
        , comp.group_name
        , comp.parent_id
        , comp.rank_level
        , comp.description
        , s.user_id
        from nc_device_group comp
        inner join
        (select distinct group_id, user_id from nc_device_permission_stream where delete_flag = 0 and user_id=#{userId}) s
        on comp.group_id=s.group_id
        where rank_level=1 and delete_flag = 0
    </select>
 
    <select id="getByUserPermsAs" resultMap="deviceGroupExtPermsMapAs" parameterType="String">
       select comp.group_id
        , comp.group_name
        , comp.parent_id
        , comp.rank_level
        , comp.description
        , comp.CREATE_TIME
        , comp.UPDATE_TIME
        , comp.create_by
        , comp.update_by
        from nc_device_group comp
        inner join
        (select distinct group_id from nc_device_permission_stream where delete_flag = 0 and user_id=#{userId}) s
        on comp.group_id=s.group_id
        where delete_flag = 0
    </select>
 
    <select id="getByParentIdAndUserPerms" resultMap="deviceGroupExtPermsMap" parameterType="java.util.Map">
        select comp.group_id
        , comp.group_name
        , comp.parent_id
        , comp.rank_level
        , comp.description
        , s.user_id
        from nc_device_group comp
        inner join
        (select distinct group_id, user_id from nc_device_permission_stream where delete_flag = 0 and user_id=#{userId}) s
        on comp.group_id=s.group_id
        where delete_flag = 0 and parent_id=#{parentId}
    </select>
 
    <select id="findById" resultMap="deviceGroupExtPermsMapAs" parameterType="Map">
         select comp.group_id
        , comp.group_name
        , comp.parent_id
        , comp.rank_level
        , comp.description
        from nc_device_group comp
        where comp.delete_flag = 0 and comp.group_id=#{id}
    </select>
</mapper>