<?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.deploy.mapper.SysApkInfoMapper">
    
    <resultMap type="SysApkInfo" id="SysApkInfoResult">
        <result property="id"    column="id"    />
        <result property="uploadingType"    column="uploading_type"    />
        <result property="sysApkName"    column="sys_apk_name"    />
        <result property="version"    column="version"    />
        <result property="sysApk"    column="sys_apk"    />
        <result property="sysApkSize"    column="sys_apk_size"    />
        <result property="sysType"    column="sys_type"    />
        <result property="uploadingStatus"    column="uploading_status"    />
        <result property="uploadingLogId"    column="uploading_log_id"    />
        <result property="orderNum"    column="order_num"    />
        <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="selectSysApkInfoVo">
        select id, uploading_type, sys_apk_name, version, sys_apk, sys_apk_size, sys_type, uploading_status, uploading_log_id, order_num, is_delete, created, modified, create_time, update_time from SYS_APK_INFO
    </sql>

    <select id="selectSysApkInfoList" parameterType="SysApkInfo" resultMap="SysApkInfoResult">
        <include refid="selectSysApkInfoVo"/>
        <where>  
            <if test="uploadingType != null  and uploadingType != ''"> and uploading_type = #{uploadingType}</if>
            <if test="sysApkName != null  and sysApkName != ''"> and sys_apk_name like concat('%', #{sysApkName}, '%')</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="sysType != null  and sysType != ''"> and sys_type = #{sysType}</if>
            <if test="uploadingStatus != null "> and uploading_status = #{uploadingStatus}</if>
            <if test="created != null  and created != ''"> and created = #{created}</if>
        </where>
    </select>
    
    <select id="selectSysApkInfoById" parameterType="Long" resultMap="SysApkInfoResult">
        <include refid="selectSysApkInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysApkInfo" parameterType="SysApkInfo" useGeneratedKeys="true" keyProperty="id">
        insert into SYS_APK_INFO
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uploadingType != null and uploadingType != ''">uploading_type,</if>
            <if test="sysApkName != null and sysApkName != ''">sys_apk_name,</if>
            <if test="version != null and version != ''">version,</if>
            <if test="sysApk != null">sys_apk,</if>
            <if test="sysApkSize != null">sys_apk_size,</if>
            <if test="sysType != null and sysType != ''">sys_type,</if>
            <if test="uploadingStatus != null">uploading_status,</if>
            <if test="uploadingLogId != null">uploading_log_id,</if>
            <if test="orderNum != null">order_num,</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="uploadingType != null and uploadingType != ''">#{uploadingType},</if>
            <if test="sysApkName != null and sysApkName != ''">#{sysApkName},</if>
            <if test="version != null and version != ''">#{version},</if>
            <if test="sysApk != null">#{sysApk},</if>
            <if test="sysApkSize != null">#{sysApkSize},</if>
            <if test="sysType != null and sysType != ''">#{sysType},</if>
            <if test="uploadingStatus != null">#{uploadingStatus},</if>
            <if test="uploadingLogId != null">#{uploadingLogId},</if>
            <if test="orderNum != null">#{orderNum},</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="updateSysApkInfo" parameterType="SysApkInfo">
        update SYS_APK_INFO
        <trim prefix="SET" suffixOverrides=",">
            <if test="uploadingType != null and uploadingType != ''">uploading_type = #{uploadingType},</if>
            <if test="sysApkName != null and sysApkName != ''">sys_apk_name = #{sysApkName},</if>
            <if test="version != null and version != ''">version = #{version},</if>
            <if test="sysApk != null">sys_apk = #{sysApk},</if>
            <if test="sysApkSize != null">sys_apk_size = #{sysApkSize},</if>
            <if test="sysType != null and sysType != ''">sys_type = #{sysType},</if>
            <if test="uploadingStatus != null">uploading_status = #{uploadingStatus},</if>
            <if test="uploadingLogId != null">uploading_log_id = #{uploadingLogId},</if>
            <if test="orderNum != null">order_num = #{orderNum},</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="deleteSysApkInfoById" parameterType="Long">
        delete from SYS_APK_INFO where id = #{id}
    </delete>

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