<?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.tasktypedict.TaskTypeDictMapper">

    <resultMap type="TaskTypeDict" id="TaskTypeDictResult">
        <result property="id" column="id"/>
        <result property="taskTypeName" column="task_type_name"/>
        <result property="taskTypeCode" column="task_type_code"/>
        <result property="taskTypeSort" column="task_type_sort"/>
        <result property="taskTypeRemark" column="task_type_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="selectTaskTypeDictVo">
        select id,
               task_type_name,
               task_type_code,
               task_type_sort,
               task_type_remark,
               create_by,
               create_time,
               update_by,
               update_time
        from task_type_dict
    </sql>

    <select id="selectTaskTypeDictList" parameterType="TaskTypeDict" resultMap="TaskTypeDictResult">
        <include refid="selectTaskTypeDictVo"/>
        <where>
            <if test="taskTypeName != null  and taskTypeName != ''">
                and task_type_name like concat('%', #{taskTypeName}, '%')
            </if>
            <if test="taskTypeCode != null  and taskTypeCode != ''">
                and task_type_code = #{taskTypeCode}
            </if>
            <if test="taskTypeSort != null ">
                and task_type_sort = #{taskTypeSort}
            </if>
            <if test="taskTypeRemark != null  and taskTypeRemark != ''">
                and task_type_remark = #{taskTypeRemark}
            </if>
        </where>
    </select>

    <select id="selectTaskTypeDictById" parameterType="Long"
            resultMap="TaskTypeDictResult">
        <include refid="selectTaskTypeDictVo"/>
        where id = #{id}
    </select>

    <insert id="insertTaskTypeDict" parameterType="TaskTypeDict" useGeneratedKeys="true"
            keyProperty="id">
        insert into task_type_dict
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskTypeName != null">task_type_name,
            </if>
            <if test="taskTypeCode != null">task_type_code,
            </if>
            <if test="taskTypeSort != null">task_type_sort,
            </if>
            <if test="taskTypeRemark != null">task_type_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="taskTypeName != null">#{taskTypeName},
            </if>
            <if test="taskTypeCode != null">#{taskTypeCode},
            </if>
            <if test="taskTypeSort != null">#{taskTypeSort},
            </if>
            <if test="taskTypeRemark != null">#{taskTypeRemark},
            </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="updateTaskTypeDict" parameterType="TaskTypeDict">
        update task_type_dict
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskTypeName != null">task_type_name =
                #{taskTypeName},
            </if>
            <if test="taskTypeCode != null">task_type_code =
                #{taskTypeCode},
            </if>
            <if test="taskTypeSort != null">task_type_sort =
                #{taskTypeSort},
            </if>
            <if test="taskTypeRemark != null">task_type_remark =
                #{taskTypeRemark},
            </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="deleteTaskTypeDictById" parameterType="Long">
        delete
        from task_type_dict
        where id = #{id}
    </delete>

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