OrganizationMapper.xml
3.51 KB
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
<?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.xiniunet.service.railway.dal.OrganizationMapper">
<sql id="whereForFindList">
<if test="request.code!=null"> AND `CODE` LIKE CONCAT ('%',#{ request.code },'%')</if>
<if test="request.type!=null"> AND `TYPE` LIKE CONCAT ('%',#{ request.type },'%')</if>
<if test="request.name!=null"> AND `NAME` LIKE CONCAT ('%',#{ request.name },'%')</if>
<if test="request.description!=null"> AND `DESCRIPTION` LIKE CONCAT ('%',#{ request.description },'%')</if>
</sql>
<sql id="whereForSearchList">
AND
(
1=0
OR `CODE` LIKE CONCAT ('%',#{ request.keyword },'%')
OR `TYPE` LIKE CONCAT ('%',#{ request.keyword },'%')
OR `NAME` LIKE CONCAT ('%',#{ request.keyword },'%')
OR `DESCRIPTION` LIKE CONCAT ('%',#{ request.keyword },'%')
)
</sql>
<select id="find" resultMap="organizationPO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ORGANIZATION`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
<select id="findCount" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ORGANIZATION`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<include refid="whereForFindList" />
</select>
<select id="search" resultMap="organizationPO">
SELECT
<include refid="entityColumnList"/>
FROM
`RW_ORGANIZATION`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<if test="request.keyword !=null">
<include refid="whereForSearchList" />
</if>
<if test="request.pageSize !=0">
LIMIT #{ request.beginItemIndex }, #{ request.pageSize }
</if>
</select>
<select id="searchCount" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ORGANIZATION`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
<if test="request.keyword !=null">
<include refid="whereForSearchList" />
</if>
</select>
<select id="existByCode" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
`RW_ORGANIZATION`
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
AND `ID` != #{id}
AND `CODE` = #{code}
</select>
<update id="update">
UPDATE
`RW_ORGANIZATION`
SET
`PID`=#{ request.pid },
`CODE`=#{ request.code },
`TYPE`=#{ request.type },
`NAME`=#{ request.name },
`DESCRIPTION`=#{ request.description },
`LAST_UPDATED_BY`=#{ passport.userId },
`LAST_UPDATE_TIME`=SYSDATE(),
`ROW_VERSION`=#{ request.rowVersion }+1
WHERE
`IS_DELETED`=0
AND `TENANT_ID`=#{ passport.tenantId }
AND `ID` = #{ request.id }
AND `ROW_VERSION` = #{ request.rowVersion }
</update>
</mapper>