<?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.zehong.system.mapper.TInsSurListInforMapper">
    
    <resultMap type="TInsSurListInfor" id="TInsSurListInforResult">
        <result property="fInsSurListInforId"    column="f_ins_sur_list_infor_id"    />
        <result property="fCheckTaskCode"    column="f_check_task_code"    />
        <result property="fTypeCode"    column="f_type_code"    />
        <result property="fContents"    column="f_contents"    />
        <result property="fResType"    column="f_res_type"    />
        <result property="fResOption"    column="f_res_option"    />
        <result property="ord"    column="ord"    />
        <result property="fLastUpdateTime"    column="f_last_update_time"    />
    </resultMap>

    <sql id="selectTInsSurListInforVo">
        select f_ins_sur_list_infor_id, f_check_task_code, f_type_code, f_contents, f_res_type, f_res_option, ord, f_last_update_time from t_ins_sur_list_infor
    </sql>

    <select id="selectTInsSurListInforList" parameterType="TInsSurListInfor" resultMap="TInsSurListInforResult">
        <include refid="selectTInsSurListInforVo"/>
        <where>  
            <if test="fTypeCode != null  and fTypeCode != ''"> and f_type_code = #{fTypeCode}</if>
            <if test="fResType != null "> and f_res_type = #{fResType}</if>
            <if test="fCheckTaskCode != null  and fCheckTaskCode != ''"> and f_check_task_code = #{fCheckTaskCode}</if>
        </where>
        ORDER BY f_last_update_time DESC
    </select>
    
    <select id="selectTInsSurListInforById" parameterType="Long" resultMap="TInsSurListInforResult">
        <include refid="selectTInsSurListInforVo"/>
        where f_ins_sur_list_infor_id = #{fInsSurListInforId}
    </select>
        
    <insert id="insertTInsSurListInfor" parameterType="TInsSurListInfor" useGeneratedKeys="true" keyProperty="fInsSurListInforId">
        insert into t_ins_sur_list_infor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fCheckTaskCode != null">f_check_task_code,</if>
            <if test="fTypeCode != null">f_type_code,</if>
            <if test="fContents != null">f_contents,</if>
            <if test="fResType != null">f_res_type,</if>
            <if test="fResOption != null">f_res_option,</if>
            <if test="ord != null">ord,</if>
            <if test="fLastUpdateTime != null">f_last_update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fCheckTaskCode != null">#{fCheckTaskCode},</if>
            <if test="fTypeCode != null">#{fTypeCode},</if>
            <if test="fContents != null">#{fContents},</if>
            <if test="fResType != null">#{fResType},</if>
            <if test="fResOption != null">#{fResOption},</if>
            <if test="ord != null">#{ord},</if>
            <if test="fLastUpdateTime != null">#{fLastUpdateTime},</if>
         </trim>
    </insert>

    <update id="updateTInsSurListInfor" parameterType="TInsSurListInfor">
        update t_ins_sur_list_infor
        <trim prefix="SET" suffixOverrides=",">
            <if test="fCheckTaskCode != null">f_check_task_code = #{fCheckTaskCode},</if>
            <if test="fTypeCode != null">f_type_code = #{fTypeCode},</if>
            <if test="fContents != null">f_contents = #{fContents},</if>
            <if test="fResType != null">f_res_type = #{fResType},</if>
            <if test="fResOption != null">f_res_option = #{fResOption},</if>
            <if test="ord != null">ord = #{ord},</if>
            <if test="fLastUpdateTime != null">f_last_update_time = #{fLastUpdateTime},</if>
        </trim>
        where f_ins_sur_list_infor_id = #{fInsSurListInforId}
    </update>

    <delete id="deleteTInsSurListInforById" parameterType="Long">
        delete from t_ins_sur_list_infor where f_ins_sur_list_infor_id = #{fInsSurListInforId}
    </delete>

    <delete id="deleteTInsSurListInforByIds" parameterType="String">
        delete from t_ins_sur_list_infor where f_ins_sur_list_infor_id in 
        <foreach item="fInsSurListInforId" collection="array" open="(" separator="," close=")">
            #{fInsSurListInforId}
        </foreach>
    </delete>

    <insert id="batchInsertTInsSurListInfor" parameterType="TInsSurListInfor" useGeneratedKeys="true" keyProperty="fInsSurListInforId">
        insert into t_ins_sur_list_infor(
            f_check_task_code,
            f_type_code,
            f_contents,
            f_res_type,
            f_res_option,
            ord,
            f_last_update_time
        )VALUES
        <foreach collection="list" separator="," item="item">
            (
                #{item.fCheckTaskCode},
                #{item.fTypeCode},
                #{item.fContents},
                #{item.fResType},
                #{item.fResOption},
                #{item.ord},
                #{item.fLastUpdateTime}
            )
        </foreach>
    </insert>
</mapper>