<?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.ruoyi.pda.mapper.PdaApkVersionMapper">
    
    <resultMap type="PdaApkVersion" id="PdaApkVersionResult">
        <result property="objid"    column="objid"    />
        <result property="versionCode"    column="version_code"    />
        <result property="versionName"    column="version_name"    />
        <result property="modifyContent"    column="modify_content"    />
        <result property="downloadUrl"    column="download_url"    />
        <result property="apkSize"    column="apk_size"    />
        <result property="apkMd5"    column="apk_md5"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPdaApkVersionVo">
        select objid, version_code, version_name, modify_content, download_url, apk_size, apk_md5, create_time from pda_apk_version
    </sql>

    <select id="selectPdaApkVersionList" parameterType="PdaApkVersion" resultMap="PdaApkVersionResult">
        <include refid="selectPdaApkVersionVo"/>
        <where>  
            <if test="versionCode != null "> and version_code = #{versionCode}</if>
        </where>
    </select>
    
    <select id="selectPdaApkVersionByObjid" parameterType="Long" resultMap="PdaApkVersionResult">
        <include refid="selectPdaApkVersionVo"/>
        where objid = #{objid}
    </select>
        
    <insert id="insertPdaApkVersion" parameterType="PdaApkVersion" useGeneratedKeys="true" keyProperty="objid">
        insert into pda_apk_version
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="versionCode != null">version_code,</if>
            <if test="versionName != null">version_name,</if>
            <if test="modifyContent != null">modify_content,</if>
            <if test="downloadUrl != null">download_url,</if>
            <if test="apkSize != null">apk_size,</if>
            <if test="apkMd5 != null">apk_md5,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="versionCode != null">#{versionCode},</if>
            <if test="versionName != null">#{versionName},</if>
            <if test="modifyContent != null">#{modifyContent},</if>
            <if test="downloadUrl != null">#{downloadUrl},</if>
            <if test="apkSize != null">#{apkSize},</if>
            <if test="apkMd5 != null">#{apkMd5},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updatePdaApkVersion" parameterType="PdaApkVersion">
        update pda_apk_version
        <trim prefix="SET" suffixOverrides=",">
            <if test="versionCode != null">version_code = #{versionCode},</if>
            <if test="versionName != null">version_name = #{versionName},</if>
            <if test="modifyContent != null">modify_content = #{modifyContent},</if>
            <if test="downloadUrl != null">download_url = #{downloadUrl},</if>
            <if test="apkSize != null">apk_size = #{apkSize},</if>
            <if test="apkMd5 != null">apk_md5 = #{apkMd5},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deletePdaApkVersionByObjid" parameterType="Long">
        delete from pda_apk_version where objid = #{objid}
    </delete>

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

</mapper>