<?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.taskpartitiondict.TaskPartitionDictMapper">

    <resultMap type="TaskPartitionDict" id="TaskPartitionDictResult">
        <result property="id" column="id"/>
        <result property="taskTypeId" column="task_type_id"/>
        <result property="taskTypeName" column="task_type_name"/>
        <result property="taskPartitionName" column="task_partition_name"/>
        <result property="taskPartitionCode" column="task_partition_code"/>
        <result property="secondClassifyDescribe" column="second_classify_describe"/>
        <result property="executionTime" column="execution_time"/>
        <result property="taskPartitionSort" column="task_partition_sort"/>
        <result property="taskPartitionRemark" column="task_partition_remark"/>
        <result property="taskPartitionContent" column="task_partition_content"/>
        <result property="templateType" column="template_type"/>
        <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="selectTaskPartitionDictVo">
        select id,
               task_type_id,
               task_type_name,
               task_partition_name,
               task_partition_code,
               second_classify_describe,
               execution_time,
               task_partition_sort,
               task_partition_remark,
               task_partition_content,
               template_type,
               create_by,
               create_time,
               update_by,
               update_time
        from task_partition_dict
    </sql>

    <select id="selectTaskPartitionDictList" parameterType="TaskPartitionDict" resultMap="TaskPartitionDictResult">
        <include refid="selectTaskPartitionDictVo"/>
        <where>
            <if test="taskTypeId != null ">
                and task_type_id = #{taskTypeId}
            </if>
            <if test="taskTypeName != null  and taskTypeName != ''">
                and task_type_name like concat('%', #{taskTypeName}, '%')
            </if>
            <if test="taskPartitionName != null  and taskPartitionName != ''">
                and task_partition_name like concat('%', #{taskPartitionName}, '%')
            </if>
            <if test="taskPartitionCode != null  and taskPartitionCode != ''">
                and task_partition_code = #{taskPartitionCode}
            </if>
            <if test="secondClassifyDescribe != null  and secondClassifyDescribe != ''">
                and second_classify_describe = #{secondClassifyDescribe}
            </if>
            <if test="executionTime != null ">
                and execution_time = #{executionTime}
            </if>
            <if test="taskPartitionSort != null ">
                and task_partition_sort = #{taskPartitionSort}
            </if>
            <if test="taskPartitionRemark != null  and taskPartitionRemark != ''">
                and task_partition_remark = #{taskPartitionRemark}
            </if>
            <if test="templateType != null  and templateType != ''">
                and template_type = #{templateType}
            </if>
        </where>
    </select>

    <select id="selectTaskPartitionDictById" parameterType="Long"
            resultMap="TaskPartitionDictResult">
        <include refid="selectTaskPartitionDictVo"/>
        where id = #{id}
    </select>

    <insert id="insertTaskPartitionDict" parameterType="TaskPartitionDict" useGeneratedKeys="true"
            keyProperty="id">
        insert into task_partition_dict
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskTypeId != null">task_type_id,
            </if>
            <if test="taskTypeName != null">task_type_name,
            </if>
            <if test="taskPartitionName != null">task_partition_name,
            </if>
            <if test="taskPartitionCode != null">task_partition_code,
            </if>
            <if test="secondClassifyDescribe != null">second_classify_describe,
            </if>
            <if test="executionTime != null">execution_time,
            </if>
            <if test="taskPartitionSort != null">task_partition_sort,
            </if>
            <if test="taskPartitionRemark != null">task_partition_remark,
            </if>
            <if test="taskPartitionContent != null">task_partition_content,
            </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="templateType != null">template_type,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskTypeId != null">#{taskTypeId},
            </if>
            <if test="taskTypeName != null">#{taskTypeName},
            </if>
            <if test="taskPartitionName != null">#{taskPartitionName},
            </if>
            <if test="taskPartitionCode != null">#{taskPartitionCode},
            </if>
            <if test="secondClassifyDescribe != null">#{secondClassifyDescribe},
            </if>
            <if test="executionTime != null">#{executionTime},
            </if>
            <if test="taskPartitionSort != null">#{taskPartitionSort},
            </if>
            <if test="taskPartitionRemark != null">#{taskPartitionRemark},
            </if>
            <if test="taskPartitionRemark != null">#{taskPartitionContent},
            </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="templateType != null">#{templateType},
            </if>
        </trim>
    </insert>

    <update id="updateTaskPartitionDict" parameterType="TaskPartitionDict">
        update task_partition_dict
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskTypeId != null">task_type_id =
                #{taskTypeId},
            </if>
            <if test="taskTypeName != null">task_type_name =
                #{taskTypeName},
            </if>
            <if test="taskPartitionName != null">task_partition_name =
                #{taskPartitionName},
            </if>
            <if test="taskPartitionCode != null">task_partition_code =
                #{taskPartitionCode},
            </if>
            <if test="secondClassifyDescribe != null">second_classify_describe =
                #{secondClassifyDescribe},
            </if>
            <if test="executionTime != null">execution_time =
                #{executionTime},
            </if>
            <if test="taskPartitionSort != null">task_partition_sort =
                #{taskPartitionSort},
            </if>
            <if test="taskPartitionRemark != null">task_partition_remark =
                #{taskPartitionRemark},
            </if>
            <if test="taskPartitionContent != null">task_partition_content =
                #{taskPartitionContent},
            </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="templateType != null">template_type =
                #{templateType},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTaskPartitionDictById" parameterType="Long">
        delete
        from task_partition_dict
        where id = #{id}
    </delete>

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