AppPatchDao.xml
6.29 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?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.version.impl.AppPatchDaoImpl">
<resultMap type="appPatch" id="appPatchResultMap">
<id property="id" column="id" />
<result property="creatorId" column="creator_id" />
<result property="yn" column="yn" />
<result property="sourceUrl" column="source_url" />
<result property="desUrl" column="des_url" />
<result property="patchUrl" column="patch_url" />
<result property="forceFlag" column="force_flag" />
<result property="versionDesId" column="version_des_id" />
<result property="versionDesNo" column="des_no" />
<result property="versionSourceId" column="version_source_id" />
<result property="versionSourceNo" column="source_no" />
<result property="deviceType" column="device_type" />
<result property="systemType" column="system_type" />
<result property="md5" column="md5" />
<result property="versionName" column="app_version" />
</resultMap>
<!-- 查询列来源表 -->
<sql id="QUERY_FROM_TABLE"><![CDATA[FROM T_APP_PATCH]]></sql>
<!-- 增加AppPatch -->
<insert id="save" parameterType="appPatch">
<![CDATA[
INSERT INTO T_APP_PATCH (
patch_url,
version_source_id,
version_des_id,
force_flag
) VALUES (
#{patchUrl},
#{versionSourceId},
#{versionDesId},
#{forceFlag}
)
]]>
</insert>
<!-- 根据id删除 -->
<update id="deleteById" parameterType="java.lang.Long">
<![CDATA[UPDATE T_APP_PATCH SET yn=2 WHERE id = #{id}]]>
</update>
<!-- 修改 -->
<update id="update" parameterType="appPatch">
<![CDATA[UPDATE T_APP_PATCH]]>
<set>
<if test="patchUrl != null"><![CDATA[patch_url = #{patchUrl},]]></if>
<if test="versionSourceId != null"><![CDATA[version_source_id = #{versionSourceId},]]></if>
<if test="versionDesId != null"><![CDATA[version_des_id = #{versionDesId},]]></if>
<if test="forceFlag != null"><![CDATA[force_flag = #{forceFlag},]]></if>
<if test="yn != null"><![CDATA[yn = #{yn},]]></if>
</set>
<![CDATA[WHERE id = #{id}]]>
</update>
<select id="getById" parameterType="java.lang.Long" resultMap="appPatchResultMap">
<![CDATA[SELECT
a.id,
a.patch_url,
a.version_source_id,
a.version_des_id,
a.force_flag,
a.creator_id,
a.yn,
a.created,
a.modified,
des.app_version des_no,
des.device_type,
des.system_type,
des.app_url des_url,
source.app_url source_url,
source.app_version source_no
FROM T_APP_PATCH a
LEFT JOIN T_APP_VERSION des ON
des.id=a.version_des_id
LEFT JOIN T_APP_VERSION source ON
source.id=a.version_source_id
WHERE
a.id = #{id}]]>
</select>
<select id="listByCondition" parameterType="Query" resultMap="appPatchResultMap">
<![CDATA[SELECT
a.id,
a.patch_url,
a.version_source_id,
a.version_des_id,
a.force_flag,
a.creator_id,
a.yn,
a.created,
a.modified,
des.app_version des_no,
des.device_type,
des.system_type,
des.app_url des_url,
source.app_url source_url,
source.app_version source_no
FROM T_APP_PATCH a
LEFT JOIN T_APP_VERSION des ON
des.id=a.version_des_id
LEFT JOIN T_APP_VERSION source ON
source.id=a.version_source_id
]]>
<where>
<![CDATA[a.yn = 1]]>
<if test="param.force_flag != null and param.force_flag != ''"><![CDATA[AND a.force_flag = #{param.force_flag}]]></if>
<if test="param.device_type != null and param.device_type != ''"><![CDATA[AND source.device_type = #{param.device_type}]]></if>
<if test="param.version_source_id != null and param.version_source_id != ''"><![CDATA[AND source.id = #{param.version_source_id}]]></if>
<if test="param.version_des_id != null and param.version_des_id != ''"><![CDATA[AND des.id = #{param.version_des_id}]]></if>
</where>
order by id desc
<![CDATA[
limit #{startRow},#{pageSize}
]]>
</select>
<select id="listAllByCondition" parameterType="baseQuery" resultMap="appPatchResultMap">
<![CDATA[SELECT
a.id,
a.patch_url,
a.version_source_id,
a.version_des_id,
a.force_flag,
a.creator_id,
a.yn,
a.created,
a.modified,
des.app_version des_no,
des.device_type,
des.system_type,
des.app_url des_url,
source.app_url source_url,
source.app_version source_no
FROM T_APP_PATCH a
LEFT JOIN T_APP_VERSION des ON
des.id=a.version_des_id
LEFT JOIN T_APP_VERSION source ON
source.id=a.version_source_id
]]>
<where>
<![CDATA[a.yn = 1]]>
<if test="param.device_type != null and param.device_type != ''"><![CDATA[AND source.device_type = #{param.device_type}]]></if>
<if test="param.version_source_id != null and param.version_source_id != ''"><![CDATA[AND version_source_id = #{param.version_source_id}]]></if>
<if test="param.version_des_id != null and param.version_des_id != ''"><![CDATA[AND version_des_id = #{param.version_des_id}]]></if>
</where>
</select>
<!-- 总数查询,通过条件 -->
<select id="countByCondition" parameterType="baseQuery" resultType="int">
<![CDATA[SELECT COUNT(id) AS dataCount]]>
<include refid="QUERY_FROM_TABLE" />
<where>
<![CDATA[yn = 1]]>
<if test="param.force_flag != null and param.force_flag != ''"><![CDATA[AND force_flag = #{param.force_flag}]]></if>
</where>
</select>
<select id="getPatchByVersionCode" parameterType="baseQuery" resultMap="appPatchResultMap">
<![CDATA[SELECT
a.id,
a.patch_url,
a.version_source_id,
a.version_des_id,
a.force_flag,
a.description,
a.creator_id,
a.yn,
a.created,
a.modified,
a.md5,
des.app_version
FROM T_APP_PATCH a
LEFT JOIN T_APP_VERSION des ON des.id=a.version_des_id
LEFT JOIN T_APP_VERSION source ON source.id=a.version_source_id
]]>
<where>
<![CDATA[a.yn = 1 and des.yn=1 and des.status=1]]>
<if test="param.device_type != null and param.device_type != ''"><![CDATA[AND source.device_type = #{param.device_type}]]></if>
<if test="param.sourceCode != null and param.sourceCode != ''"><![CDATA[AND source.version_code = #{param.sourceCode}]]></if>
<if test="param.desCode != null and param.desCode != ''"><![CDATA[AND des.version_code = #{param.desCode}]]></if>
</where>
</select>
</mapper>