GuardLogDao.xml
3.14 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
112
113
<?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.diligrp.mobsite.getway.dao.grardlog.impl.GuardLogmapperDaoImpl">
<resultMap type="guardLog" id="resultMap">
<id property="id" column="id" />
<result property="guardId" column="guard_id" />
<result property="guardName" column="guard_name" />
<result property="status" column="status" />
<result property="created" column="created" />
<result property="modified" column="modified" />
<result property="yn" column="yn" />
</resultMap>
<sql id="QUERY_WHERE_CLAUSE">
<![CDATA[where 1=1]]>
<if test="guardName != null and guardName != ''"><![CDATA[AND b.guard_name like CONCAT('%',#{guardName},'%')]]></if>
<if test="status != null and status != ''"><![CDATA[AND b.status = #{status}]]></if>
<if test="guardId != null and guardId != ''"><![CDATA[AND b.guard_id = #{guardId}]]></if>
</sql>
<sql id="QUERY_LIMIT_CONDTION">
<if test="startRow != null and startRow >= 0 and pageSize != null and pageSize > 0">
<![CDATA[LIMIT #{startRow},#{pageSize}]]>
</if>
</sql>
<!-- 增加AppPatch -->
<insert id="save" parameterType="guardLog">
<![CDATA[
INSERT INTO T_GUARD_LOG (
guard_id,
guard_name,
status
) VALUES (
#{guardId},
#{guardName},
#{status}
)
]]>
</insert>
<select id="listAllByCondition" parameterType="baseQuery" resultMap="resultMap">
<![CDATA[SELECT
a.id,
a.guard_id,
a.guard_name,
a.status,
a.yn,
a.created,
a.modified
FROM T_GUARD_LOG a
]]>
<where>
<![CDATA[a.yn = 1]]>
and a.guard_id = #{param.guardId}
</where>
ORDER BY a.created DESC
</select>
<select id="listByCondition" parameterType="guardQuery" resultMap="resultMap">
<![CDATA[
select b.guard_id,b.guard_name,max(b.status) status
from (
select max(created) created from T_GUARD_LOG where yn=1 GROUP BY guard_id
) t LEFT JOIN T_GUARD_LOG b on t.created = b.created
]]>
<include refid="QUERY_WHERE_CLAUSE"/>
<![CDATA[
GROUP BY guard_name,guard_id
order by b.created desc
]]>
<include refid="QUERY_LIMIT_CONDTION"/>
</select>
<select id="countByCondition" parameterType="guardQuery" resultType="int">
<![CDATA[
select count(guard_id) from (
select b.guard_id,b.guard_name,max(b.status) status
from (
select max(created) created from T_GUARD_LOG where yn=1 GROUP BY guard_id
) t LEFT JOIN T_GUARD_LOG b on t.created = b.created
]]>
<include refid="QUERY_WHERE_CLAUSE"/>
<![CDATA[
GROUP BY guard_name,guard_id
]]>
) a
</select>
<select id="listHistoryByCondition" parameterType="guardQuery" resultMap="resultMap">
<![CDATA[SELECT
b.id,
b.guard_id,
b.guard_name,
b.created,
b.status
FROM T_GUARD_LOG b
]]>
<include refid="QUERY_WHERE_CLAUSE"/>
ORDER BY b.created DESC
<include refid="QUERY_LIMIT_CONDTION"/>
</select>
<select id="countHistoryByCondition" parameterType="guardQuery" resultType="int">
<![CDATA[SELECT
count(b.id)
FROM T_GUARD_LOG b
]]>
<include refid="QUERY_WHERE_CLAUSE"/>
</select>
</mapper>