<?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.TInsTaskInforMapper">
    
    <resultMap type="TInsTaskInfor" id="TInsTaskInforResult">
        <result property="fInsTaskInforId"    column="f_ins_task_infor_id"    />
        <result property="fUniqueCode"    column="f_unique_code"    />
        <result property="fTaskBelong"    column="f_task_belong"    />
        <result property="fTaskType"    column="f_task_type"    />
        <result property="fDistributeFlag"    column="f_distribute_flag"    />
        <result property="fName"    column="f_name"    />
        <result property="fDesc"    column="f_desc"    />
        <result property="fStartTime"    column="f_start_time"    />
        <result property="fEndTime"    column="f_end_time"    />
        <result property="fStatus"    column="f_status"    />
        <result property="fDeleteFlag"    column="f_delete_flag"    />
        <result property="fRemark"    column="f_remark"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fCreateBy"    column="f_create_by"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fModifyBy"    column="f_modify_by"    />
    </resultMap>

    <sql id="selectTInsTaskInforVo">
        select f_ins_task_infor_id, f_unique_code, f_task_belong, f_task_type, f_distribute_flag, f_name, f_desc, f_start_time, f_end_time, f_status, f_delete_flag, f_remark, f_create_time, f_create_by, f_update_time, f_modify_by from t_ins_task_infor
    </sql>

    <select id="selectTInsTaskInforList" parameterType="TInsTaskInfor" resultMap="TInsTaskInforResult">
        <include refid="selectTInsTaskInforVo"/>
        <where>  
            <if test="fUniqueCode != null  and fUniqueCode != ''"> and f_unique_code like concat('%', #{fUniqueCode}, '%')</if>
            <if test="fTaskBelong != null  and fTaskBelong != ''"> and f_task_belong like concat('%', #{fTaskBelong}, '%')</if>
            <if test="fTaskType != null  and fTaskType != ''"> and f_task_type = #{fTaskType}</if>
            <if test="fDistributeFlag != null "> and f_distribute_flag = #{fDistributeFlag}</if>
            <if test="fName != null  and fName != ''"> and f_name like concat('%', #{fName}, '%')</if>
            <if test="fDesc != null  and fDesc != ''"> and f_desc = #{fDesc}</if>
            <if test="fStartTime != null  and fStartTime != ''"> and f_start_time = #{fStartTime}</if>
            <if test="fEndTime != null  and fEndTime != ''"> and f_end_time = #{fEndTime}</if>
            <if test="fStatus != null  and fStatus != ''"> and f_status = #{fStatus}</if>
            <if test="fDeleteFlag != null "> and f_delete_flag = #{fDeleteFlag}</if>
            <if test="fRemark != null  and fRemark != ''"> and f_remark = #{fRemark}</if>
            <if test="fCreateTime != null  and fCreateTime != ''"> and f_create_time = #{fCreateTime}</if>
            <if test="fCreateBy != null  and fCreateBy != ''"> and f_create_by = #{fCreateBy}</if>
            <if test="fUpdateTime != null  and fUpdateTime != ''"> and f_update_time = #{fUpdateTime}</if>
            <if test="fModifyBy != null  and fModifyBy != ''"> and f_modify_by = #{fModifyBy}</if>
        </where>
        ORDER BY f_create_time DESC
    </select>
    
    <select id="selectTInsTaskInforById" parameterType="Long" resultMap="TInsTaskInforResult">
        <include refid="selectTInsTaskInforVo"/>
        where f_ins_task_infor_id = #{fInsTaskInforId}
    </select>
        
    <insert id="insertTInsTaskInfor" parameterType="TInsTaskInfor" useGeneratedKeys="true" keyProperty="fInsTaskInforId">
        insert into t_ins_task_infor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fUniqueCode != null and fUniqueCode != ''">f_unique_code,</if>
            <if test="fTaskBelong != null and fTaskBelong != ''">f_task_belong,</if>
            <if test="fTaskType != null">f_task_type,</if>
            <if test="fDistributeFlag != null">f_distribute_flag,</if>
            <if test="fName != null">f_name,</if>
            <if test="fDesc != null">f_desc,</if>
            <if test="fStartTime != null">f_start_time,</if>
            <if test="fEndTime != null">f_end_time,</if>
            <if test="fStatus != null">f_status,</if>
            <if test="fDeleteFlag != null">f_delete_flag,</if>
            <if test="fRemark != null">f_remark,</if>
            <if test="fCreateTime != null">f_create_time,</if>
            <if test="fCreateBy != null">f_create_by,</if>
            <if test="fUpdateTime != null">f_update_time,</if>
            <if test="fModifyBy != null">f_modify_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fUniqueCode != null and fUniqueCode != ''">#{fUniqueCode},</if>
            <if test="fTaskBelong != null and fTaskBelong != ''">#{fTaskBelong},</if>
            <if test="fTaskType != null">#{fTaskType},</if>
            <if test="fDistributeFlag != null">#{fDistributeFlag},</if>
            <if test="fName != null">#{fName},</if>
            <if test="fDesc != null">#{fDesc},</if>
            <if test="fStartTime != null">#{fStartTime},</if>
            <if test="fEndTime != null">#{fEndTime},</if>
            <if test="fStatus != null">#{fStatus},</if>
            <if test="fDeleteFlag != null">#{fDeleteFlag},</if>
            <if test="fRemark != null">#{fRemark},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
            <if test="fCreateBy != null">#{fCreateBy},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>
            <if test="fModifyBy != null">#{fModifyBy},</if>
         </trim>
    </insert>

    <update id="updateTInsTaskInfor" parameterType="TInsTaskInfor">
        update t_ins_task_infor
        <trim prefix="SET" suffixOverrides=",">
            <if test="fUniqueCode != null and fUniqueCode != ''">f_unique_code = #{fUniqueCode},</if>
            <if test="fTaskBelong != null and fTaskBelong != ''">f_task_belong = #{fTaskBelong},</if>
            <if test="fTaskType != null">f_task_type = #{fTaskType},</if>
            <if test="fDistributeFlag != null">f_distribute_flag = #{fDistributeFlag},</if>
            <if test="fName != null">f_name = #{fName},</if>
            <if test="fDesc != null">f_desc = #{fDesc},</if>
            <if test="fStartTime != null">f_start_time = #{fStartTime},</if>
            <if test="fEndTime != null">f_end_time = #{fEndTime},</if>
            <if test="fStatus != null">f_status = #{fStatus},</if>
            <if test="fDeleteFlag != null">f_delete_flag = #{fDeleteFlag},</if>
            <if test="fRemark != null">f_remark = #{fRemark},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
            <if test="fCreateBy != null">f_create_by = #{fCreateBy},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
            <if test="fModifyBy != null">f_modify_by = #{fModifyBy},</if>
        </trim>
        where f_ins_task_infor_id = #{fInsTaskInforId}
    </update>

    <delete id="deleteTInsTaskInforById" parameterType="Long">
        delete from t_ins_task_infor where f_ins_task_infor_id = #{fInsTaskInforId}
    </delete>

    <delete id="deleteTInsTaskInforByIds" parameterType="String">
        delete from t_ins_task_infor where f_ins_task_infor_id in 
        <foreach item="fInsTaskInforId" collection="array" open="(" separator="," close=")">
            #{fInsTaskInforId}
        </foreach>
    </delete>

    <insert id="batchInsertTInsTaskInfo" parameterType="TInsTaskInfor" useGeneratedKeys="true" keyProperty="fInsTaskInforId">
        insert into t_ins_task_infor(
            f_unique_code,
            f_task_belong,
            f_task_type,
            f_distribute_flag,
            f_name,
            f_desc,
            f_start_time,
            f_end_time,
            f_status,
            f_delete_flag,
            f_remark,
            f_create_time,
            f_create_by,
            f_update_time,
            f_modify_by
        )values
        <foreach collection="list" separator="," item="item">
            (
                #{item.fUniqueCode},
                #{item.fTaskBelong},
                #{item.fTaskType},
                #{item.fDistributeFlag},
                #{item.fName},
                #{item.fDesc},
                #{item.fStartTime},
                #{item.fEndTime},
                #{item.fStatus},
                #{item.fDeleteFlag},
                #{item.fRemark},
                #{item.fCreateTime},
                #{item.fCreateBy},
                #{item.fUpdateTime},
                #{item.fModifyBy}
            )
        </foreach>
    </insert>
</mapper>