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.OrgUnitmanagerDao">
 
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.landtool.lanbase.modules.org.entity.OrgUnitmanager" id="unitmanagerMap">
        <result property="unitid" column="UNITID"/>
        <result property="userid" column="USERID"/>
        <result property="rcreateuser" column="RCREATEUSER"/>
        <result property="rcreatedate" column="RCREATEDATE"/>
        <result property="rlasteditdate" column="RLASTEDITDATE"/>
    </resultMap>
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.org.entity.OrgUnitmanager">
        select * from ORG_UNITMANAGER where UserID = #{value}
    </select>
 
    <select id="queryList" resultType="com.landtool.lanbase.modules.org.entity.OrgUnitmanager">
        SELECT *
        FROM(
            SELECT ROW_NUMBER() OVER(ORDER BY B.userid) AS rownumber,B.*
            FROM (
                    select * from ORG_UNITMANAGER
                ) B
        ) A
        WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
    </select>
    
     <select id="queryTotal" resultType="int">
        select count(*) from ORG_UNITMANAGER
    </select>
     
     <select id="queryUserList" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
        SELECT *
        FROM(
            SELECT ROW_NUMBER() OVER(ORDER BY B.userid) AS rownumber,B.*
            FROM (
                    select * from ORG_USER where 1 = 1 and userstatus = 0
                    and (userid not in (select userid from ORG_UNITMANAGER)
                    <if test="unitid != null and unitid != 0">
                        or userid in (select userid from ORG_UNITMANAGER where unitid = #{unitid})
                    </if>
                    )
                    <if test="chinesename != null and chinesename!=''">
                           AND (chinesename LIKE ('%' || #{chinesename} || '%') or loginname LIKE ('%' || #{chinesename} || '%') or LOWER(spellfirst) LIKE ('%' || LOWER(#{chinesename}) || '%'))
                       </if>
                ) B
        ) A
        WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
    </select>
    
     <select id="queryUserTotal" resultType="int">
        select count(*) from ORG_USER
        where 1 = 1 and userstatus = 0
        and (userid not in (select userid from ORG_UNITMANAGER)
        <if test="unitid != null and unitid != 0">
            or userid in (select userid from ORG_UNITMANAGER where unitid = #{unitid})
        </if>
        )
        <if test="chinesename != null and chinesename!=''">
            AND (chinesename LIKE ('%' || #{chinesename} || '%') or loginname LIKE ('%' || #{chinesename} || '%') or LOWER(spellfirst) LIKE ('%' || LOWER(#{chinesename}) || '%'))
        </if>
    </select>
    
    <insert id="save" parameterType="com.landtool.lanbase.modules.org.entity.OrgUnitmanager">
        insert into ORG_UNITMANAGER
        (
            UNITID, 
            USERID, 
            RCREATEUSER, 
            RCREATEDATE, 
            RLASTEDITDATE
        )
        values
        (
            #{unitid}, 
            #{userid}, 
            #{rcreateuser}, 
            #{rcreatedate}, 
            #{rlasteditdate}
        )
    </insert>
     
    <update id="update" parameterType="com.landtool.lanbase.modules.org.entity.OrgUnitmanager">
        update ORG_UNITMANAGER
        <set>
            <if test="userid != null">USERID = #{userid}, </if>
            <if test="rcreateuser != null">RCREATEUSER = #{rcreateuser}, </if>
            <if test="rcreatedate != null">RCREATEDATE = #{rcreatedate}, </if>
            <if test="rlasteditdate != null">RLASTEDITDATE = #{rlasteditdate}</if>
        </set>
        where UNITID = #{unitid}
    </update>
    
    <delete id="delete">
        delete from ORG_UNITMANAGER where UNITID = #{value}
    </delete>
    
    <delete id="deleteBatch">
        delete from ORG_UNITMANAGER where UNITID in
        <foreach item="unitid" collection="array" open="(" separator="," close=")">
            #{unitid}
        </foreach>
    </delete>
 
 
    <select id="findUnitManageUserByKeyword" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
        select userid,chinesename from ORG_USER where 1 = 1 and userstatus = 0
        and (userid not in (select userid from ORG_UNITMANAGER)
        <if test="unitid != null and unitid != 0">
            or userid in (select userid from ORG_UNITMANAGER where unitid = #{unitid})
        </if>
        )
        <if test="keyWord != null and keyWord != ''">
            and (
            LOGINNAME LIKE ('%' || #{keyWord} || '%')
            or CHINESENAME LIKE ('%' || #{keyWord} || '%')
            or LOWER(SPELLFIRST) LIKE ('%' || LOWER(#{keyWord}) || '%')
            )
        </if>
    </select>
</mapper>