<?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.BisTtsaDesignMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaDesign" id="BisTtsaDesignResult">
        <result property="guid" column="guid"/>
        <result property="planGuid" column="plan_guid"/>
        <result property="designName" column="design_name"/>
        <result property="designType" column="design_type"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="designStat" column="design_stat"/>
        <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="selectBisTtsaDesignVo">
        select guid, plan_guid, design_name, design_type, org_guid,
               design_stat, note, coll_time, upd_time, rec_pers
        from bis_ttsa_design
    </sql>

    <select id="selectBisTtsaDesignByGuid" parameterType="String" resultMap="BisTtsaDesignResult">
        <include refid="selectBisTtsaDesignVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaDesignList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesign" resultMap="BisTtsaDesignResult">
        <include refid="selectBisTtsaDesignVo"/>
        <where>
            <if test="planGuid != null and planGuid != ''">and plan_guid = #{planGuid}</if>
            <if test="designName != null and designName != ''">and design_name like concat('%', #{designName}, '%')</if>
            <if test="designStat != null and designStat != ''">and design_stat = #{designStat}</if>
        </where>
    </select>

    <insert id="insertBisTtsaDesign" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesign">
        insert into bis_ttsa_design (
            guid, plan_guid, design_name, design_type, org_guid,
            design_stat, note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{planGuid}, #{designName}, #{designType}, #{orgGuid},
            #{designStat}, #{note}, #{collTime}, #{updTime}, #{recPers}
        )
    </insert>

    <update id="updateBisTtsaDesign" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesign">
        update bis_ttsa_design
        <set>
            <if test="planGuid != null">plan_guid = #{planGuid},</if>
            <if test="designName != null">design_name = #{designName},</if>
            <if test="designType != null">design_type = #{designType},</if>
            <if test="orgGuid != null">org_guid = #{orgGuid},</if>
            <if test="designStat != null">design_stat = #{designStat},</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="deleteBisTtsaDesignByGuid" parameterType="String">
        delete from bis_ttsa_design where guid = #{guid}
    </delete>

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