<?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.TPatrolWorkInfoMapper">
    
    <resultMap type="TPatrolWorkInfo" id="TPatrolWorkInfoResult">
        <result property="workId"    column="work_id"    />
        <result property="workName"    column="work_name"    />
        <result property="workDescribe"    column="work_describe"    />
        <result property="pantrolId"    column="pantrol_id"    />
        <result property="tEmployedPeopleInfo"    column="t_employed_people_info"    />
        <result property="inspectPointNum"    column="inspect_point_num"    />
        <result property="inspectSuccessNum"    column="inspect_success_num"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTPatrolWorkInfoVo">
        select work_id, work_name, work_describe, pantrol_id, t_employed_people_info, inspect_point_num, inspect_success_num, create_by, create_time, update_by, update_time, is_del, remarks from t_patrol_work_info
    </sql>

    <select id="selectTPatrolWorkInfoList" parameterType="TPatrolWorkInfo" resultMap="TPatrolWorkInfoResult">
        <include refid="selectTPatrolWorkInfoVo"/>
        <where>  
            <if test="workName != null  and workName != ''"> and work_name like concat('%', #{workName}, '%')</if>
            <if test="workDescribe != null  and workDescribe != ''"> and work_describe = #{workDescribe}</if>
            <if test="pantrolId != null  and pantrolId != ''"> and pantrol_id = #{pantrolId}</if>
            <if test="tEmployedPeopleInfo != null "> and t_employed_people_info = #{tEmployedPeopleInfo}</if>
            <if test="inspectPointNum != null "> and inspect_point_num = #{inspectPointNum}</if>
            <if test="inspectSuccessNum != null "> and inspect_success_num = #{inspectSuccessNum}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTPatrolWorkInfoById" parameterType="Long" resultMap="TPatrolWorkInfoResult">
        <include refid="selectTPatrolWorkInfoVo"/>
        where work_id = #{workId}
    </select>
        
    <insert id="insertTPatrolWorkInfo" parameterType="TPatrolWorkInfo" useGeneratedKeys="true" keyProperty="workId">
        insert into t_patrol_work_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workName != null">work_name,</if>
            <if test="workDescribe != null">work_describe,</if>
            <if test="pantrolId != null">pantrol_id,</if>
            <if test="tEmployedPeopleInfo != null">t_employed_people_info,</if>
            <if test="inspectPointNum != null">inspect_point_num,</if>
            <if test="inspectSuccessNum != null">inspect_success_num,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workName != null">#{workName},</if>
            <if test="workDescribe != null">#{workDescribe},</if>
            <if test="pantrolId != null">#{pantrolId},</if>
            <if test="tEmployedPeopleInfo != null">#{tEmployedPeopleInfo},</if>
            <if test="inspectPointNum != null">#{inspectPointNum},</if>
            <if test="inspectSuccessNum != null">#{inspectSuccessNum},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTPatrolWorkInfo" parameterType="TPatrolWorkInfo">
        update t_patrol_work_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="workName != null">work_name = #{workName},</if>
            <if test="workDescribe != null">work_describe = #{workDescribe},</if>
            <if test="pantrolId != null">pantrol_id = #{pantrolId},</if>
            <if test="tEmployedPeopleInfo != null">t_employed_people_info = #{tEmployedPeopleInfo},</if>
            <if test="inspectPointNum != null">inspect_point_num = #{inspectPointNum},</if>
            <if test="inspectSuccessNum != null">inspect_success_num = #{inspectSuccessNum},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where work_id = #{workId}
    </update>

    <delete id="deleteTPatrolWorkInfoById" parameterType="Long">
        delete from t_patrol_work_info where work_id = #{workId}
    </delete>

    <delete id="deleteTPatrolWorkInfoByIds" parameterType="String">
        delete from t_patrol_work_info where work_id in 
        <foreach item="workId" collection="array" open="(" separator="," close=")">
            #{workId}
        </foreach>
    </delete>
</mapper>