<?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.yunfeiyun.agmp.pts.mapper.PtsLinkVersionMapper">
    
    <resultMap type="PtsLinkVersion" id="PtsLinkVersionResult">
        <result property="versionId"    column="versionId"    />
        <result property="linkId"    column="linkId"    />
        <result property="versionNo"    column="versionNo"    />
        <result property="versionModifieddate"    column="versionModifieddate"    />
        <result property="versionRemark"    column="versionRemark"    />

    </resultMap>

    <sql id="selectPtsLinkVersionVo">
        select versionId, linkId, versionNo, versionModifieddate,versionRemark from PtsLinkVersion
    </sql>

    <select id="selectPtsLinkVersionList" parameterType="PtsLinkVersion" resultMap="PtsLinkVersionResult">
        <include refid="selectPtsLinkVersionVo"/>
        <where>  
            <if test="linkId != null  and linkId != ''"> and linkId = #{linkId}</if>
            <if test="versionNo != null  and versionNo != ''"> and versionNo = #{versionNo}</if>
            <if test="versionModifieddate != null  and versionModifieddate != ''"> and versionModifieddate = #{versionModifieddate}</if>
        </where>
    </select>
    
    <select id="selectPtsLinkVersionByVersionId" parameterType="String" resultMap="PtsLinkVersionResult">
        <include refid="selectPtsLinkVersionVo"/>
        where versionId = #{versionId}
    </select>

    <select id="selectPtsLinkVersionMaxByVersionId" parameterType="String" resultMap="PtsLinkVersionResult">
        select versionId, linkId, max(versionNo), versionModifieddate, versionRemark from PtsLinkVersion
        where versionId = #{versionId} limit 1
    </select>

        
    <insert id="insertPtsLinkVersion" parameterType="PtsLinkVersion">
        insert into PtsLinkVersion
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="versionId != null">versionId,</if>
            <if test="linkId != null">linkId,</if>
            <if test="versionNo != null">versionNo,</if>
            <if test="versionModifieddate != null">versionModifieddate,</if>
            <if test="versionRemark != null">versionRemark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="versionId != null">#{versionId},</if>
            <if test="linkId != null">#{linkId},</if>
            <if test="versionNo != null">#{versionNo},</if>
            <if test="versionModifieddate != null">#{versionModifieddate},</if>
            <if test="versionRemark != null">#{versionRemark},</if>
         </trim>
    </insert>

    <update id="updatePtsLinkVersion" parameterType="PtsLinkVersion">
        update PtsLinkVersion
        <trim prefix="SET" suffixOverrides=",">
            <if test="linkId != null">linkId = #{linkId},</if>
            <if test="versionNo != null">versionNo = #{versionNo},</if>
            <if test="versionModifieddate != null">versionModifieddate = #{versionModifieddate},</if>
            <if test="versionRemark != null">#{versionRemark},</if>
        </trim>
        where versionId = #{versionId}
    </update>

    <delete id="deletePtsLinkVersionByVersionId" parameterType="String">
        delete from PtsLinkVersion where versionId = #{versionId}
    </delete>

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