AppPatchDao.xml
4.81 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
<?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.man.dao.impl.AppPatchDaoImpl">
<resultMap type="appPatch" id="appPatchResultMap">
<id property="id" column="id" />
<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="description" column="description" />
<result property="md5" column="md5" />
<result property="creatorId" column="creator_id" />
<result property="yn" column="yn" />
</resultMap>
<!-- 来源表 -->
<sql id="QUERY_FROM_TABLE"><![CDATA[FROM T_APP_PATCH]]></sql>
<!-- 连接查询语句 -->
<sql id="QUERY_SELECT">
<![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 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]]>
</sql>
<!-- 增加AppPatch -->
<insert id="save" parameterType="appPatch">
<![CDATA[
INSERT INTO T_APP_PATCH (
version_source_id,
version_des_id,
force_flag,
patch_url,
description,
md5
) VALUES (
#{versionSourceId},
#{versionDesId},
#{forceFlag},
#{patchUrl},
#{description},
#{md5}
)
]]>
</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="description != null"><![CDATA[description = #{description},]]></if>
<if test="md5 != null"><![CDATA[md5 = #{md5},]]></if>
<if test="yn != null"><![CDATA[yn = #{yn},]]></if>
</set>
<![CDATA[WHERE id = #{id}]]>
</update>
<select id="getById" parameterType="java.lang.Long" resultMap="appPatchResultMap">
<include refid="QUERY_SELECT"></include>
<![CDATA[
WHERE
a.id = #{id}]]>
</select>
<select id="listByCondition" parameterType="Query" resultMap="appPatchResultMap">
<include refid="QUERY_SELECT"></include>
<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">
<include refid="QUERY_SELECT"></include>
<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>
</mapper>