AppVersionDao.xml 4.63 KB
<?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.AppVersionDaoImpl">

	 <resultMap type="appVersion" id="appVersionResultMap">
		<id property="id" column="id" />
		<result property="deviceType" column="device_type" />
		<result property="appVersion" column="app_version" />
		<result property="appUrl" column="app_url" />
		<result property="description" column="description" />
		<result property="systemType" column="system_type" />
		<result property="status" column="status" />
		<result property="forceFlag" column="force_flag" />
		<result property="creatorId" column="creator_id" />
		<result property="patchFlag" column="patch_flag" />
		<result property="versionCode" column="version_code" />
	</resultMap>

    <!-- 所有查询列 -->
	<sql id="QUERY_COLUMN_LIST">
		<![CDATA[id,device_type,app_version,app_url,description,status,force_flag,patch_flag,creator_id,created,modified,version_code]]>
	</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="deviceType != null and deviceType != ''"><![CDATA[AND device_type = #{deviceType}]]></if>
			<if test="appVersion != null and appVersion != ''"><![CDATA[AND app_version = #{appVersion}]]></if>
			<if test="appUrl != null and appUrl != ''"><![CDATA[AND app_url = #{appUrl}]]></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="forceFlag != null and forceFlag != ''"><![CDATA[AND force_flag = #{forceFlag}]]></if>
			<if test="creatorId != null and creatorId != ''"><![CDATA[AND creator_id = #{creatorId}]]></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 &gt;= 0 and pageSize != null and pageSize &gt; 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
	</sql>

	<!-- 更新列字段,只要不为NULL则更新,除开主键列 -->
	<sql id="UPDATE_COLUMN_SET">
		<set>
			<if test="deviceType != null"><![CDATA[device_type = #{deviceType},]]></if>
			<if test="appVersion != null"><![CDATA[app_version = #{appVersion},]]></if>
			<if test="appUrl != null"><![CDATA[app_url = #{appUrl},]]></if>
			<if test="description != null"><![CDATA[description = #{description},]]></if>
			<if test="status != null"><![CDATA[status = #{status},]]></if>
			<if test="forceFlag != null"><![CDATA[force_flag = #{forceFlag},]]></if>
			<if test="creatorId != null"><![CDATA[creator_id = #{creatorId},]]></if>
		</set>
	</sql>

	<!-- 根据版本号进行查询 -->
	<select id="getByVersion" parameterType="java.lang.String" resultMap="appVersionResultMap">
		<![CDATA[SELECT]]>
		<include refid="QUERY_COLUMN_LIST" />
		<include refid="QUERY_FROM_TABLE" />
		<![CDATA[WHERE status=1 and yn=1 and app_version = #{version} and system_type=#{systemType}]]>
	</select>

	<!-- 查询最新的版本 -->
	<select id="getLastAppVersion" parameterType="baseQuery" resultMap="appVersionResultMap">
		<![CDATA[SELECT]]>
		<include refid="QUERY_COLUMN_LIST" />
		<include refid="QUERY_FROM_TABLE" />
		<where>
			<![CDATA[yn = 1 AND status = 1]]>
			<if test="param.deviceType != null and param.deviceType != ''"><![CDATA[AND device_type = #{param.deviceType}]]></if>
	        <if test="param.systemType != null and param.systemType != ''"><![CDATA[AND system_type = #{param.systemType}]]></if>
	        <if test="param.versionCode != null and param.versionCode != ''"><![CDATA[AND version_code > #{param.versionCode}]]></if>
		</where>
		<![CDATA[ORDER BY version_code DESC LIMIT 0 ,1]]>
	</select>
	
	<!-- 查询列表 -->
	<select id="listByCondition" parameterType="baseQuery" resultMap="appVersionResultMap">
		<![CDATA[SELECT]]>
		<include refid="QUERY_COLUMN_LIST" />
		<include refid="QUERY_FROM_TABLE" />
		<where>
			<![CDATA[yn = 1 AND status = 1]]>
			<if test="param.deviceType != null and param.deviceType != ''"><![CDATA[AND device_type = #{param.deviceType}]]></if>
            <if test="param.systemType != null and param.systemType != ''"><![CDATA[AND system_type = #{param.systemType}]]></if>
		</where>
		<![CDATA[order by app_version desc]]>
	</select>

	
</mapper>