<?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.xinelu.manage.mapper.taskstatusdict.TaskStatusDictMapper">

    <resultMap type="TaskStatusDict" id="TaskStatusDictResult">
        <result property="id" column="id"/>
        <result property="taskPartitionId" column="task_partition_id"/>
        <result property="taskPartitionName" column="task_partition_name"/>
        <result property="taskStatusName" column="task_status_name"/>
        <result property="taskStatusCode" column="task_status_code"/>
        <result property="taskStatusSort" column="task_status_sort"/>
        <result property="taskStatusRemark" column="task_status_remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectTaskStatusDictVo">
        select id,
               task_partition_id,
               task_partition_name,
               task_status_name,
               task_status_code,
               task_status_sort,
               task_status_remark,
               create_by,
               create_time,
               update_by,
               update_time
        from task_status_dict
    </sql>

    <select id="selectTaskStatusDictList" parameterType="TaskStatusDict" resultMap="TaskStatusDictResult">
        <include refid="selectTaskStatusDictVo"/>
        <where>
            <if test="taskPartitionId != null ">
                and task_partition_id = #{taskPartitionId}
            </if>
            <if test="taskPartitionName != null  and taskPartitionName != ''">
                and task_partition_name like concat('%', #{taskPartitionName}, '%')
            </if>
            <if test="taskStatusName != null  and taskStatusName != ''">
                and task_status_name like concat('%', #{taskStatusName}, '%')
            </if>
            <if test="taskStatusCode != null  and taskStatusCode != ''">
                and task_status_code = #{taskStatusCode}
            </if>
            <if test="taskStatusSort != null ">
                and task_status_sort = #{taskStatusSort}
            </if>
            <if test="taskStatusRemark != null  and taskStatusRemark != ''">
                and task_status_remark = #{taskStatusRemark}
            </if>
        </where>
    </select>

    <select id="selectTaskStatusDictById" parameterType="Long"
            resultMap="TaskStatusDictResult">
        <include refid="selectTaskStatusDictVo"/>
        where id = #{id}
    </select>

    <insert id="insertTaskStatusDict" parameterType="TaskStatusDict" useGeneratedKeys="true"
            keyProperty="id">
        insert into task_status_dict
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskPartitionId != null">task_partition_id,
            </if>
            <if test="taskPartitionName != null">task_partition_name,
            </if>
            <if test="taskStatusName != null">task_status_name,
            </if>
            <if test="taskStatusCode != null">task_status_code,
            </if>
            <if test="taskStatusSort != null">task_status_sort,
            </if>
            <if test="taskStatusRemark != null">task_status_remark,
            </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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskPartitionId != null">#{taskPartitionId},
            </if>
            <if test="taskPartitionName != null">#{taskPartitionName},
            </if>
            <if test="taskStatusName != null">#{taskStatusName},
            </if>
            <if test="taskStatusCode != null">#{taskStatusCode},
            </if>
            <if test="taskStatusSort != null">#{taskStatusSort},
            </if>
            <if test="taskStatusRemark != null">#{taskStatusRemark},
            </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>
        </trim>
    </insert>

    <update id="updateTaskStatusDict" parameterType="TaskStatusDict">
        update task_status_dict
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskPartitionId != null">task_partition_id =
                #{taskPartitionId},
            </if>
            <if test="taskPartitionName != null">task_partition_name =
                #{taskPartitionName},
            </if>
            <if test="taskStatusName != null">task_status_name =
                #{taskStatusName},
            </if>
            <if test="taskStatusCode != null">task_status_code =
                #{taskStatusCode},
            </if>
            <if test="taskStatusSort != null">task_status_sort =
                #{taskStatusSort},
            </if>
            <if test="taskStatusRemark != null">task_status_remark =
                #{taskStatusRemark},
            </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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTaskStatusDictById" parameterType="Long">
        delete
        from task_status_dict
        where id = #{id}
    </delete>

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