<?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.djhk.uav.versioninfo.mapper.VersionInfoMapper">
    
    <resultMap type="com.djhk.uav.versioninfo.domain.VersionInfo" id="VersionInfoResult">
        <result property="id"    column="id"    />
        <result property="versionNum"    column="version_num"    />
        <result property="versiontime"    column="versiontime"    />
        <result property="content"    column="content"    />
        <result property="companyInfo"    column="company_info"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectVersionInfoVo">
        select id, version_num, versiontime, content, company_info, del_flag, create_by, create_time, update_by, update_time, remark from version_info
    </sql>

    <select id="selectVersionInfoList" parameterType="com.djhk.uav.versioninfo.domain.VersionInfo" resultMap="VersionInfoResult">
        <include refid="selectVersionInfoVo"/>
        <where>  
            <if test="versionNum != null  and versionNum != ''"> and version_num = #{versionNum}</if>
            <if test="versiontime != null  and versiontime != ''"> and versiontime = #{versiontime}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="companyInfo != null  and companyInfo != ''"> and company_info = #{companyInfo}</if>
        </where>
    </select>
    
    <select id="selectVersionInfoById" parameterType="Long" resultMap="VersionInfoResult">
        <include refid="selectVersionInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertVersionInfo" parameterType="com.djhk.uav.versioninfo.domain.VersionInfo" useGeneratedKeys="true" keyProperty="id">
        insert into version_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="versionNum != null">version_num,</if>
            <if test="versiontime != null">versiontime,</if>
            <if test="content != null">content,</if>
            <if test="companyInfo != null">company_info,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="versionNum != null">#{versionNum},</if>
            <if test="versiontime != null">#{versiontime},</if>
            <if test="content != null">#{content},</if>
            <if test="companyInfo != null">#{companyInfo},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateVersionInfo" parameterType="com.djhk.uav.versioninfo.domain.VersionInfo">
        update version_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="versionNum != null">version_num = #{versionNum},</if>
            <if test="versiontime != null">versiontime = #{versiontime},</if>
            <if test="content != null">content = #{content},</if>
            <if test="companyInfo != null">company_info = #{companyInfo},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVersionInfoById" parameterType="Long">
        delete from version_info where id = #{id}
    </delete>

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