<?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.goldenwater.slaj.ttsa.mapper.ObjTtsaMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.ObjTtsa" id="ObjTtsaResult">
        <result property="guid" column="guid"/>
        <result property="persTtsGuid" column="pers_tts_guid"/>
        <result property="applStat" column="appl_stat"/>
        <result property="veriStat" column="veri_stat"/>
        <result property="veriOpin" column="veri_opin"/>
        <result property="apprStat" column="appr_stat"/>
        <result property="apprOpin" column="appr_opin"/>
        <result property="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
        <result property="veriPers" column="veri_pers"/>
        <result property="veriTime" column="veri_time"/>
        <result property="apprPers" column="appr_pers"/>
        <result property="apprTime" column="appr_time"/>
        <result property="punoGuid" column="puno_guid"/>
        <result property="examStat" column="exam_stat"/>
        <result property="examApplGuid" column="exam_appl_guid"/>
        <result property="applTime" column="appl_time"/>
    </resultMap>

    <sql id="selectObjTtsaVo">
        select guid, pers_tts_guid, appl_stat, veri_stat, veri_opin,
               appr_stat, appr_opin, note, coll_time, upd_time,
               rec_pers, veri_pers, veri_time, appr_pers, appr_time,
               puno_guid, exam_stat, exam_appl_guid, appl_time
        from obj_ttsa
    </sql>

    <select id="selectObjTtsaByGuid" parameterType="String" resultMap="ObjTtsaResult">
        <include refid="selectObjTtsaVo"/> where guid = #{guid}
    </select>

    <select id="selectObjTtsaList" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTtsa" resultMap="ObjTtsaResult">
        <include refid="selectObjTtsaVo"/>
        <where>
            <if test="persTtsGuid != null and persTtsGuid != ''">and pers_tts_guid = #{persTtsGuid}</if>
            <if test="applStat != null and applStat != ''">and appl_stat = #{applStat}</if>
            <if test="veriStat != null and veriStat != ''">and veri_stat = #{veriStat}</if>
        </where>
    </select>

    <insert id="insertObjTtsa" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTtsa">
        insert into obj_ttsa (
            guid, pers_tts_guid, appl_stat, veri_stat, veri_opin,
            appr_stat, appr_opin, note, coll_time, upd_time,
            rec_pers, veri_pers, veri_time, appr_pers, appr_time,
            puno_guid, exam_stat, exam_appl_guid, appl_time
        ) values (
            #{guid}, #{persTtsGuid}, #{applStat}, #{veriStat}, #{veriOpin},
            #{apprStat}, #{apprOpin}, #{note}, #{collTime}, #{updTime},
            #{recPers}, #{veriPers}, #{veriTime}, #{apprPers}, #{apprTime},
            #{punoGuid}, #{examStat}, #{examApplGuid}, #{applTime}
        )
    </insert>

    <update id="updateObjTtsa" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTtsa">
        update obj_ttsa
        <set>
            <if test="persTtsGuid != null">pers_tts_guid = #{persTtsGuid},</if>
            <if test="applStat != null">appl_stat = #{applStat},</if>
            <if test="veriStat != null">veri_stat = #{veriStat},</if>
            <if test="veriOpin != null">veri_opin = #{veriOpin},</if>
            <if test="apprStat != null">appr_stat = #{apprStat},</if>
            <if test="apprOpin != null">appr_opin = #{apprOpin},</if>
            <if test="note != null">note = #{note},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
            <if test="veriPers != null">veri_pers = #{veriPers},</if>
            <if test="veriTime != null">veri_time = #{veriTime},</if>
            <if test="apprPers != null">appr_pers = #{apprPers},</if>
            <if test="apprTime != null">appr_time = #{apprTime},</if>
            <if test="punoGuid != null">puno_guid = #{punoGuid},</if>
            <if test="examStat != null">exam_stat = #{examStat},</if>
            <if test="examApplGuid != null">exam_appl_guid = #{examApplGuid},</if>
            <if test="applTime != null">appl_time = #{applTime},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteObjTtsaByGuid" parameterType="String">
        delete from obj_ttsa where guid = #{guid}
    </delete>

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