<?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.huashe.park.core.mapper.ParkInspectTaskMapper">
    
    <resultMap type="ParkInspectTask" id="ParkInspectTaskResult">
        <result property="id"    column="id"    />
        <result property="taskName"    column="task_name"    />
        <result property="remark"    column="remark"    />
        <result property="schedule"    column="schedule"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectParkInspectTaskVo">
        select id, task_name, remark, schedule, update_time, create_time, create_by, update_by, tenant_id from park_inspect_task
    </sql>

    <select id="selectParkInspectTaskList" parameterType="ParkInspectTask" resultMap="ParkInspectTaskResult">
        <include refid="selectParkInspectTaskVo"/>
        <where>  
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
        </where>
    </select>
    
    <select id="selectParkInspectTaskById" parameterType="Long" resultMap="ParkInspectTaskResult">
        <include refid="selectParkInspectTaskVo"/>
        where id = #{id}
    </select>

    <insert id="insertParkInspectTask" parameterType="ParkInspectTask" useGeneratedKeys="true" keyProperty="id">
        insert into park_inspect_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskName != null">task_name,</if>
            <if test="remark != null">remark,</if>
            <if test="schedule != null">schedule,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="tenantId != null">tenant_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskName != null">#{taskName},</if>
            <if test="remark != null">#{remark},</if>
            <if test="schedule != null">#{schedule},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="tenantId != null">#{tenantId},</if>
         </trim>
    </insert>

    <update id="updateParkInspectTask" parameterType="ParkInspectTask">
        update park_inspect_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="schedule != null">schedule = #{schedule},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteParkInspectTaskById" parameterType="Long">
        delete from park_inspect_task where id = #{id}
    </delete>

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