AppPatchDao.xml 6.29 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.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>