AppVersionDao.xml
7.41 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
<?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.AppVersionDaoImpl">
<resultMap type="AppVersion" id="appVersionResultMap">
<id property="id" column="id" />
<result property="device_type" column="device_type" />
<result property="app_version" column="app_version" />
<result property="app_url" column="app_url" />
<result property="description" column="description" />
<result property="status" column="status" />
<result property="force_flag" column="force_flag" />
<result property="systemType" column="system_type" />
<result property="creator_id" column="creator_id" />
<result property="versionCode" column="version_code" />
<result property="patchFlag" column="patch_flag" />
</resultMap>
<!-- 所有查询列 -->
<sql id="QUERY_COLUMN_LIST">
<![CDATA[id,device_type,app_version,app_url,description,status,force_flag,system_type,creator_id,created,modified,version_code,patch_flag]]>
</sql>
<!-- 查询列来源表 -->
<sql id="QUERY_FROM_TABLE"><![CDATA[FROM T_APP_VERSION]]></sql>
<!-- 全部条件(更多功能可以通过queryData扩展实现) -->
<sql id="QUERY_WHERE_CLAUSE">
<where>
<if test="id != null and id != ''"><![CDATA[AND id = #{id}]]></if>
<if test="device_type != null and device_type != ''"><![CDATA[AND device_type = #{device_type}]]></if>
<if test="app_version != null and app_version != ''"><![CDATA[AND app_version = #{app_version}]]></if>
<if test="app_url != null and app_url != ''"><![CDATA[AND app_url = #{app_url}]]></if>
<if test="description != null and description != ''"><![CDATA[AND description = #{description}]]></if>
<if test="status != null and status != ''"><![CDATA[AND status = #{status}]]></if>
<if test="force_flag != null and force_flag != ''"><![CDATA[AND force_flag = #{force_flag}]]></if>
<if test="systemType != null and systemType != ''"><![CDATA[AND system_type = #{systemType}]]></if>
<if test="creator_id != null and creator_id != ''"><![CDATA[AND creator_id = #{creator_id}]]></if>
<if test="versionCode != null and versionCode != ''"><![CDATA[AND version_code = #{versionCode}]]></if>
<if test="patchFlag != null and patchFlag != ''"><![CDATA[AND patch_flag = #{patchFlag}]]></if>
</where>
</sql>
<!-- 智能排序与分页 -->
<sql id="QUERY_ORDER_LIMIT_CONDTION">
<if test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY ${orderField} ${orderFieldType}]]></if>
<if test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
</sql>
<!-- 更新列字段,只要不为NULL则更新,除开主键列 -->
<sql id="UPDATE_COLUMN_SET">
<set>
<if test="device_type != null"><![CDATA[device_type = #{device_type},]]></if>
<if test="app_version != null"><![CDATA[app_version = #{app_version},]]></if>
<if test="app_url != null"><![CDATA[app_url = #{app_url},]]></if>
<if test="description != null"><![CDATA[description = #{description},]]></if>
<if test="status != null"><![CDATA[status = #{status},]]></if>
<if test="force_flag != null"><![CDATA[force_flag = #{force_flag},]]></if>
<if test="creator_id != null"><![CDATA[creator_id = #{creator_id},]]></if>
<if test="yn != null"><![CDATA[yn = #{yn},]]></if>
<if test="versionCode != null"><![CDATA[version_code = #{versionCode},]]></if>
<if test="patchFlag != null"><![CDATA[patch_flag = #{patchFlag},]]></if>
</set>
</sql>
<!-- 插入appVersion记录 -->
<insert id="save" parameterType="appVersion">
<![CDATA[
INSERT INTO T_APP_VERSION (device_type,app_version,app_url,description,status,force_flag,system_type,creator_id,version_code,patch_flag)
VALUES (#{device_type},#{app_version},#{app_url},#{description},#{status},#{force_flag},#{systemType},#{creator_id},#{versionCode},#{patchFlag})
]]>
</insert>
<!-- 根据id删除 -->
<update id="deleteById" parameterType="java.lang.Long">
<![CDATA[UPDATE T_APP_VERSION SET yn=2 WHERE id = #{id}]]>
</update>
<!-- 修改记录通过主键 -->
<update id="update" parameterType="appVersion">
<![CDATA[UPDATE T_APP_VERSION]]>
<include refid="UPDATE_COLUMN_SET" />
<![CDATA[WHERE id = #{id}]]>
</update>
<update id="unActiveByDeviceType" parameterType="java.lang.Integer">
<![CDATA[
UPDATE T_APP_VERSION SET status = 2
WHERE yn = 1 AND status = 1 AND device_type = #{deviceType} AND system_type = #{systemType}
]]>
</update>
<select id="getById" parameterType="java.lang.Long" resultMap="appVersionResultMap">
<![CDATA[SELECT]]>
<include refid="QUERY_COLUMN_LIST" />
<include refid="QUERY_FROM_TABLE" />
<where>
<![CDATA[id = #{id}]]>
</where>
</select>
<!-- 查询列表 -->
<select id="listByCondition" parameterType="baseQuery" resultMap="appVersionResultMap">
<![CDATA[SELECT]]>
<include refid="QUERY_COLUMN_LIST" />
<include refid="QUERY_FROM_TABLE" />
<where>
<![CDATA[yn = 1]]>
<if test="param.device_type != null and param.device_type != ''"><![CDATA[AND device_type = #{param.device_type}]]></if>
<if test="param.versionCode != null and param.versionCode != ''"><![CDATA[AND version_code = #{param.versionCode}]]></if>
<if test="param.app_version != null and param.app_version != ''"><![CDATA[AND app_version = #{param.app_version}]]></if>
<if test="param.force_flag != null and param.force_flag != ''"><![CDATA[AND force_flag = #{param.force_flag}]]></if>
<if test="param.systemType != null and param.systemType != ''"><![CDATA[AND system_type = #{param.systemType}]]></if>
</where>
order by id desc
<![CDATA[
limit #{startRow},#{pageSize}
]]>
</select>
<select id="listAllByCondition" parameterType="baseQuery" resultMap="appVersionResultMap">
<![CDATA[SELECT]]>
<include refid="QUERY_COLUMN_LIST" />
<include refid="QUERY_FROM_TABLE" />
<where>
<![CDATA[yn = 1]]>
<if test="param.device_type != null and param.device_type != ''"><![CDATA[AND device_type = #{param.device_type}]]></if>
<if test="param.app_version != null and param.app_version != ''"><![CDATA[AND app_version = #{param.app_version}]]></if>
<if test="param.force_flag != null and param.force_flag != ''"><![CDATA[AND force_flag = #{param.force_flag}]]></if>
<if test="param.systemType != null and param.systemType != ''"><![CDATA[AND system_type = #{param.systemType}]]></if>
</where>
order by id desc
</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.device_type != null and param.device_type != ''"><![CDATA[AND device_type = #{param.device_type}]]></if>
<if test="param.app_version != null and param.app_version != ''"><![CDATA[AND app_version = #{param.app_version}]]></if>
<if test="param.versionCode != null and param.versionCode != ''"><![CDATA[AND version_code = #{param.versionCode}]]></if>
<if test="param.force_flag != null and param.force_flag != ''"><![CDATA[AND force_flag = #{param.force_flag}]]></if>
<if test="param.systemType != null and param.systemType != ''"><![CDATA[AND system_type = #{param.systemType}]]></if>
</where>
</select>
</mapper>