<?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.ObjTtsMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.ObjTts" id="ObjTtsResult">
        <result property="guid" column="guid"/>
        <result property="persGuid" column="pers_guid"/>
        <result property="orgProjDeptGuid" column="org_proj_dept_guid"/>
        <result property="citNum" column="cit_num"/>
        <result property="persName" column="pers_name"/>
        <result property="bornPlac" column="born_plac"/>
        <result property="persType" column="pers_type"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="sex" column="sex"/>
        <result property="bornDate" column="born_date"/>
        <result property="highEdu" column="high_edu"/>
        <result property="techTit" column="tech_tit"/>
        <result property="schlName" column="schl_name"/>
        <result property="major" column="major"/>
        <result property="grauDate" column="grau_date"/>
        <result property="workDate" column="work_date"/>
        <result property="postDate" column="post_date"/>
        <result property="bemoDate" column="bemo_date"/>
        <result property="workResum" column="work_resum"/>
        <result property="archEngSm" column="arch_eng_sm"/>
        <result property="postDuty" column="post_duty"/>
        <result property="ttsaGuid" column="ttsa_guid"/>
        <result property="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
    </resultMap>

    <sql id="selectObjTtsVo">
        select guid, pers_guid, org_proj_dept_guid, cit_num, pers_name,
               born_plac, pers_type, org_guid, sex, born_date,
               high_edu, tech_tit, schl_name, major, grau_date,
               work_date, post_date, bemo_date, work_resum, arch_eng_sm,
               post_duty, ttsa_guid, note, coll_time, upd_time, rec_pers
        from obj_tts
    </sql>

    <select id="selectObjTtsByGuid" parameterType="String" resultMap="ObjTtsResult">
        <include refid="selectObjTtsVo"/> where guid = #{guid}
    </select>

    <select id="selectObjTtsList" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTts" resultMap="ObjTtsResult">
        <include refid="selectObjTtsVo"/>
        <where>
            <if test="persName != null and persName != ''">and pers_name like '%' || #{persName} || '%'</if>
            <if test="persType != null and persType != ''">and pers_type = #{persType}</if>
            <if test="orgGuid != null and orgGuid != ''">and org_guid = #{orgGuid}</if>
            <if test="citNum != null and citNum != ''">and cit_num = #{citNum}</if>
        </where>
    </select>

    <insert id="insertObjTts" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTts">
        insert into obj_tts (
            guid, pers_guid, org_proj_dept_guid, cit_num, pers_name,
            born_plac, pers_type, org_guid, sex, born_date,
            high_edu, tech_tit, schl_name, major, grau_date,
            work_date, post_date, bemo_date, work_resum, arch_eng_sm,
            post_duty, ttsa_guid, note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{persGuid}, #{orgProjDeptGuid}, #{citNum}, #{persName},
            #{bornPlac}, #{persType}, #{orgGuid}, #{sex}, #{bornDate},
            #{highEdu}, #{techTit}, #{schlName}, #{major}, #{grauDate},
            #{workDate}, #{postDate}, #{bemoDate}, #{workResum}, #{archEngSm},
            #{postDuty}, #{ttsaGuid}, #{note}, #{collTime}, #{updTime}, #{recPers}
        )
    </insert>

    <update id="updateObjTts" parameterType="com.goldenwater.slaj.ttsa.domain.ObjTts">
        update obj_tts
        <set>
            <if test="persGuid != null">pers_guid = #{persGuid},</if>
            <if test="orgProjDeptGuid != null">org_proj_dept_guid = #{orgProjDeptGuid},</if>
            <if test="citNum != null">cit_num = #{citNum},</if>
            <if test="persName != null">pers_name = #{persName},</if>
            <if test="bornPlac != null">born_plac = #{bornPlac},</if>
            <if test="persType != null">pers_type = #{persType},</if>
            <if test="orgGuid != null">org_guid = #{orgGuid},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="bornDate != null">born_date = #{bornDate},</if>
            <if test="highEdu != null">high_edu = #{highEdu},</if>
            <if test="techTit != null">tech_tit = #{techTit},</if>
            <if test="schlName != null">schl_name = #{schlName},</if>
            <if test="major != null">major = #{major},</if>
            <if test="grauDate != null">grau_date = #{grauDate},</if>
            <if test="workDate != null">work_date = #{workDate},</if>
            <if test="postDate != null">post_date = #{postDate},</if>
            <if test="bemoDate != null">bemo_date = #{bemoDate},</if>
            <if test="workResum != null">work_resum = #{workResum},</if>
            <if test="archEngSm != null">arch_eng_sm = #{archEngSm},</if>
            <if test="postDuty != null">post_duty = #{postDuty},</if>
            <if test="ttsaGuid != null">ttsa_guid = #{ttsaGuid},</if>
            <if test="note != null">note = #{note},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteObjTtsByGuid" parameterType="String">
        delete from obj_tts where guid = #{guid}
    </delete>

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