<?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.TInsSpotRecInforMapper">
    
    <resultMap type="TInsSpotRecInfor" id="TInsSpotRecInforResult">
        <result property="fInsSpotRecInforId"    column="f_ins_spot_rec_infor_id"    />
        <result property="fCheckCode"    column="f_check_code"    />
        <result property="fName"    column="f_name"    />
        <result property="fContent"    column="f_content"    />
        <result property="fMethod"    column="f_method"    />
        <result property="fResult"    column="f_result"    />
        <result property="fUpdateTime"    column="f_update_time"    />

        <result property="govUploadState"    column="f_gov_upload_state"    />
        <result property="govUploadTime"    column="f_gov_upload_time"    />
    </resultMap>

    <sql id="selectTInsSpotRecInforVo">
        SELECT
            spot.f_ins_spot_rec_infor_id,
            spot.f_check_code,
            spot.f_name,
            spot.f_content,
            spot.f_method,
            spot.f_result,
            spot.f_update_time,
            spot.f_gov_upload_state,
            spot.f_gov_upload_time,
            rec.f_check_task_code AS taskCode,
            task.f_name AS taskName
        FROM
            t_ins_spot_rec_infor spot
        LEFT JOIN t_ins_rec_infor rec ON rec.f_check_code = spot.f_check_code
        LEFT JOIN t_ins_task_infor task ON task.f_unique_code = rec.f_check_task_code
    </sql>

    <select id="selectTInsSpotRecInforList" parameterType="TInsSpotRecInfor" resultMap="TInsSpotRecInforResult">
        <include refid="selectTInsSpotRecInforVo"/>
        <where>  
            <if test="fCheckCode != null  and fCheckCode != ''"> and spot.f_check_code like concat('%', #{fCheckCode}, '%')</if>
            <if test="fName != null  and fName != ''"> and spot.f_name like concat('%', #{fName}, '%')</if>
            <if test="fMethod != null  and fMethod != ''"> and spot.f_method = #{fMethod}</if>
            <if test="govUploadState != null  and govUploadState != ''"> and spot.f_gov_upload_state = #{govUploadState}</if>
        </where>
    </select>
    
    <select id="selectTInsSpotRecInforById" parameterType="Long" resultMap="TInsSpotRecInforResult">
        <include refid="selectTInsSpotRecInforVo"/>
        where spot.f_ins_spot_rec_infor_id = #{fInsSpotRecInforId}
    </select>
        
    <insert id="insertTInsSpotRecInfor" parameterType="TInsSpotRecInfor" useGeneratedKeys="true" keyProperty="fInsSpotRecInforId">
        insert into t_ins_spot_rec_infor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fCheckCode != null and fCheckCode != ''">f_check_code,</if>
            <if test="fName != null and fName != ''">f_name,</if>
            <if test="fContent != null">f_content,</if>
            <if test="fMethod != null and fMethod != ''">f_method,</if>
            <if test="fResult != null">f_result,</if>
            <if test="fUpdateTime != null">f_update_time,</if>

            <if test="govUploadState != null">f_gov_upload_state,</if>
            <if test="govUploadTime != null">f_gov_upload_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fCheckCode != null and fCheckCode != ''">#{fCheckCode},</if>
            <if test="fName != null and fName != ''">#{fName},</if>
            <if test="fContent != null">#{fContent},</if>
            <if test="fMethod != null and fMethod != ''">#{fMethod},</if>
            <if test="fResult != null">#{fResult},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>

            <if test="govUploadState != null">#{govUploadState},</if>
            <if test="govUploadTime != null">#{govUploadTime},</if>
         </trim>
    </insert>

    <update id="updateTInsSpotRecInfor" parameterType="TInsSpotRecInfor">
        update t_ins_spot_rec_infor
        <trim prefix="SET" suffixOverrides=",">
            <if test="fCheckCode != null and fCheckCode != ''">f_check_code = #{fCheckCode},</if>
            <if test="fName != null and fName != ''">f_name = #{fName},</if>
            <if test="fContent != null">f_content = #{fContent},</if>
            <if test="fMethod != null and fMethod != ''">f_method = #{fMethod},</if>
            <if test="fResult != null">f_result = #{fResult},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>

            <if test="govUploadState != null">f_gov_upload_state = #{govUploadState},</if>
            <if test="govUploadTime != null">f_gov_upload_time = #{govUploadTime},</if>
        </trim>
        where f_ins_spot_rec_infor_id = #{fInsSpotRecInforId}
    </update>

    <delete id="deleteTInsSpotRecInforById" parameterType="Long">
        delete from t_ins_spot_rec_infor where f_ins_spot_rec_infor_id = #{fInsSpotRecInforId}
    </delete>

    <delete id="deleteTInsSpotRecInforByIds" parameterType="String">
        delete from t_ins_spot_rec_infor where f_ins_spot_rec_infor_id in 
        <foreach item="fInsSpotRecInforId" collection="array" open="(" separator="," close=")">
            #{fInsSpotRecInforId}
        </foreach>
    </delete>
</mapper>