1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
113
114
115
116
117
118
119
120
121
122
<?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.landtool.lanbase.modules.org.dao.OrgGroupDao">
 
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.landtool.lanbase.modules.org.entity.OrgGroup" id="groupMap">
        <result property="groupId" column="groupid"/>
        <result property="groupName" column="groupname"/>
        <result property="appId" column="appId"/>
        <result property="description" column="description"/>
        <result property="rCreateUser" column="rcreateuser"/>
        <result property="rCreateDate" column="rcreatedate"/>
    </resultMap>
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.org.entity.OrgGroup">
        select * from ORG_GROUP where groupid = #{value}
    </select>
 
    <select id="queryList" resultType="com.landtool.lanbase.modules.org.entity.OrgGroup">
        select * from (
            SELECT *
            FROM(
                SELECT ROW_NUMBER() OVER(ORDER BY B.groupid) AS rownumber,B.*
                FROM (
    
                       select gro.*,ss.appfullname,
                       (select COUNT(*) from ORG_USERGROUP o where o.groupid = gro.groupid) as TOTALOFUSERS,
                       (select COUNT(*) from SYS_ROLEGROUP r where r.groupid = gro.groupid) as TOTALOFROLES
                       from ORG_GROUP gro
                       left join SYS_SYSTEMINFO ss on ss.appid = gro.appid
                        <where>
                            <if test="groupName != null and groupName != ''">
                                AND gro.groupName LIKE ('%' || #{groupName} || '%')
                            </if>
                            <if test="appId != null and appId != ''">
                                AND cast(ss.APPID as varchar) = #{appId}
                            </if>
                        </where>
    
                ) B
            ) A
            WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
        )a order by  
        <choose>
            <when test="sidx != null and sidx != ''">
                ${sidx} ${order}
            </when>
            <otherwise>
                groupid 
            </otherwise>
        </choose>
    </select>
    
     <select id="queryTotal" resultType="int">
        select count(*) from ORG_GROUP gro
        LEFT JOIN (
            SELECT ous.groupid ,COUNT(ous.userid) as TOTALOFUSERS  
            from ORG_USERGROUP ous  GROUP BY ous.groupid
        ) b on gro.groupid = b.groupid
        left join SYS_SYSTEMINFO ss on ss.appid = gro.appid
        <where>
            <if test="groupName != null and groupName != ''">
                AND gro.groupName LIKE ('%' || #{groupName} || '%')
            </if>
            <if test="appId != null and appId != ''">
                AND cast(ss.APPID as varchar) = #{appId}
            </if>
        </where>
    </select>
     
    <insert id="save" parameterType="com.landtool.lanbase.modules.org.entity.OrgGroup">
        insert into ORG_GROUP
        (
            groupname,
            appid,
            description, 
            rcreateuser,
            rcreatedate
        )
        values
        (
            #{groupName},
            #{appId},
            #{description,jdbcType=VARCHAR},
            #{rCreateUser},
            #{rCreateDate}
        )
    </insert>
     
    <update id="update" parameterType="com.landtool.lanbase.modules.org.entity.OrgGroup">
        update ORG_GROUP
        <set>
            <if test="groupName != null">groupname = #{groupName}, </if>
            <if test="appId != null">appid = #{appId}, </if>
            <if test="description != null">description = #{description}, </if>
            <if test="rCreateUser != null">rcreateuser = #{rCreateUser}, </if>
            <if test="rCreateDate != null">rcreatedate = #{rCreateDate}</if>
        </set>
        where groupid = #{groupId}
    </update>
    
    <delete id="delete">
        delete from ORG_GROUP where groupid = #{value}
    </delete>
    
    <delete id="deleteBatch">
        delete from ORG_GROUP where groupid in
        <foreach item="groupId" collection="array" open="(" separator="," close=")">
            #{groupId}
        </foreach>
    </delete>
    
    <select id="queryListById" resultType="com.landtool.lanbase.modules.org.entity.OrgGroup">
        select * from ORG_GROUP org
            left join SYS_SYSTEMINFO syst  on syst.appid = org.appid
            where org.appid = 0 or syst.appid = #{appId}
    </select>
    
    <select id="queryGroupWithSEQ" resultType="int">
        SELECT currval('ORG_GROUP_SEQ') FROM DUAL
    </select>
</mapper>