<?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.sf.system.deployment.mapper.DeploymentServicePublishMapper">
    
    <resultMap type="DeploymentServicePublish" id="DeploymentServicePublishResult">
        <result property="id"    column="id"    />
        <result property="applyId"    column="apply_id"    />
        <result property="appName"    column="app_name"    />
        <result property="systemType"    column="system_type"    />
        <result property="apkId"    column="apk_id"    />
        <result property="appStoreAddress"    column="app_store_address"    />
        <result property="version"    column="version"    />
        <result property="versionDesc"    column="version_desc"    />
        <result property="publishEnvironment"    column="publish_environment"    />
        <result property="publishStrategy"    column="publish_strategy"    />
        <result property="resultNotify"    column="result_notify"    />
        <result property="publicVersion"    column="public_version"    />
        <result property="forceUpdate"    column="force_update"    />
        <result property="downloadVerification"    column="download_verification"    />
        <result property="updateObject"    column="update_object"    />
        <result property="validityStartTime"    column="validity_start_time"    />
        <result property="validityEndTime"    column="validity_end_time"    />
        <result property="remark"    column="remark"    />
        <result property="status"    column="status"    />
        <result property="isDelete"    column="is_delete"    />
        <result property="created"    column="created"    />
        <result property="modified"    column="modified"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDeploymentServicePublishVo">
        select id, apply_id, app_name, system_type, apk_id, app_store_address, version, version_desc, publish_environment, publish_strategy, result_notify, public_version, force_update, download_verification, update_object, validity_start_time, validity_end_time, remark, status, is_delete, created, modified, create_time, update_time from DEPLOYMENT_SERVICE_PUBLISH
    </sql>

    <select id="selectDeploymentServicePublishList" parameterType="DeploymentServicePublish" resultMap="DeploymentServicePublishResult">
        <include refid="selectDeploymentServicePublishVo"/>
        <where>  
            <if test="appName != null  and appName != ''"> and app_name like concat('%', #{appName}, '%')</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="validityStartTime != null "> and validity_start_time = #{validityStartTime}</if>
            <if test="validityEndTime != null "> and validity_end_time = #{validityEndTime}</if>
        </where>
    </select>
    
    <select id="selectDeploymentServicePublishById" parameterType="Long" resultMap="DeploymentServicePublishResult">
        <include refid="selectDeploymentServicePublishVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertDeploymentServicePublish" parameterType="DeploymentServicePublish" useGeneratedKeys="true" keyProperty="id">
        insert into DEPLOYMENT_SERVICE_PUBLISH
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applyId != null">apply_id,</if>
            <if test="appName != null and appName != ''">app_name,</if>
            <if test="systemType != null and systemType != ''">system_type,</if>
            <if test="apkId != null and apkId != ''">apk_id,</if>
            <if test="appStoreAddress != null">app_store_address,</if>
            <if test="version != null and version != ''">version,</if>
            <if test="versionDesc != null">version_desc,</if>
            <if test="publishEnvironment != null">publish_environment,</if>
            <if test="publishStrategy != null">publish_strategy,</if>
            <if test="resultNotify != null">result_notify,</if>
            <if test="publicVersion != null">public_version,</if>
            <if test="forceUpdate != null">force_update,</if>
            <if test="downloadVerification != null">download_verification,</if>
            <if test="updateObject != null">update_object,</if>
            <if test="validityStartTime != null">validity_start_time,</if>
            <if test="validityEndTime != null">validity_end_time,</if>
            <if test="remark != null">remark,</if>
            <if test="status != null">status,</if>
            <if test="isDelete != null">is_delete,</if>
            <if test="created != null">created,</if>
            <if test="modified != null">modified,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="applyId != null">#{applyId},</if>
            <if test="appName != null and appName != ''">#{appName},</if>
            <if test="systemType != null and systemType != ''">#{systemType},</if>
            <if test="apkId != null and apkId != ''">#{apkId},</if>
            <if test="appStoreAddress != null">#{appStoreAddress},</if>
            <if test="version != null and version != ''">#{version},</if>
            <if test="versionDesc != null">#{versionDesc},</if>
            <if test="publishEnvironment != null">#{publishEnvironment},</if>
            <if test="publishStrategy != null">#{publishStrategy},</if>
            <if test="resultNotify != null">#{resultNotify},</if>
            <if test="publicVersion != null">#{publicVersion},</if>
            <if test="forceUpdate != null">#{forceUpdate},</if>
            <if test="downloadVerification != null">#{downloadVerification},</if>
            <if test="updateObject != null">#{updateObject},</if>
            <if test="validityStartTime != null">#{validityStartTime},</if>
            <if test="validityEndTime != null">#{validityEndTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="isDelete != null">#{isDelete},</if>
            <if test="created != null">#{created},</if>
            <if test="modified != null">#{modified},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateDeploymentServicePublish" parameterType="DeploymentServicePublish">
        update DEPLOYMENT_SERVICE_PUBLISH
        <trim prefix="SET" suffixOverrides=",">
            <if test="applyId != null">apply_id = #{applyId},</if>
            <if test="appName != null and appName != ''">app_name = #{appName},</if>
            <if test="systemType != null and systemType != ''">system_type = #{systemType},</if>
            <if test="apkId != null and apkId != ''">apk_id = #{apkId},</if>
            <if test="appStoreAddress != null">app_store_address = #{appStoreAddress},</if>
            <if test="version != null and version != ''">version = #{version},</if>
            <if test="versionDesc != null">version_desc = #{versionDesc},</if>
            <if test="publishEnvironment != null">publish_environment = #{publishEnvironment},</if>
            <if test="publishStrategy != null">publish_strategy = #{publishStrategy},</if>
            <if test="resultNotify != null">result_notify = #{resultNotify},</if>
            <if test="publicVersion != null">public_version = #{publicVersion},</if>
            <if test="forceUpdate != null">force_update = #{forceUpdate},</if>
            <if test="downloadVerification != null">download_verification = #{downloadVerification},</if>
            <if test="updateObject != null">update_object = #{updateObject},</if>
            <if test="validityStartTime != null">validity_start_time = #{validityStartTime},</if>
            <if test="validityEndTime != null">validity_end_time = #{validityEndTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="created != null">created = #{created},</if>
            <if test="modified != null">modified = #{modified},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDeploymentServicePublishById" parameterType="Long">
        delete from DEPLOYMENT_SERVICE_PUBLISH where id = #{id}
    </delete>

    <delete id="deleteDeploymentServicePublishByIds" parameterType="String">
        delete from DEPLOYMENT_SERVICE_PUBLISH where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>