<?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.bonus.material.work.mapper.SysWorkflowTypeMapper">
    <resultMap type="com.bonus.material.work.domain.SysWorkflowType" id="SysWorkflowTypeResult">
        <result property="id"    column="id"    />
        <result property="typeName"    column="type_name"    />
        <result property="taskType"    column="task_type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="isEnable"    column="is_enable"    />
    </resultMap>

    <sql id="selectSysWorkflowTypeVo">
        select id, type_name, task_type, create_by, create_time, is_enable from sys_workflow_type
    </sql>
    <insert id="addSysWorkflowType" parameterType="com.bonus.material.work.domain.SysWorkflowType">
        insert into sys_workflow_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="typeName != null">type_name,</if>
            <if test="taskType != null">task_type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isEnable != null">is_enable,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="typeName != null">#{typeName},</if>
            <if test="taskType != null">#{taskType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isEnable != null">#{isEnable},</if>
        </trim>
    </insert>
    <update id="updateSysWorkflowType" parameterType="com.bonus.material.work.domain.SysWorkflowType">
        update sys_workflow_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeName != null">type_name = #{typeName},</if>
            <if test="taskType != null">task_type = #{taskType},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteSysWorkflowType">
        delete  from sys_workflow_type where id = #{id}
    </delete>

    <select id="selectSysWorkflowTypeList" parameterType="com.bonus.material.work.domain.SysWorkflowType" resultType="com.bonus.material.work.domain.SysWorkflowType">
        select swt.id as id, swt.type_name as typeName, swt.task_type as taskType,sdd.dict_label as taskName, swt.create_by as createBy,
               swt.create_time as createTime, swt.is_enable as isEnable
         from sys_workflow_type swt
         left join sys_dict_data sdd on swt.task_type =sdd.dict_value
          where sdd.dict_type='tm_task_type'

            <if test="typeName != null "> and type_name like concat('%', #{typeName}, '%')</if>
            <if test="taskType != null "> and task_type = #{taskType}</if>
            <if test="createBy != null "> and create_by = #{createBy}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="isEnable != null "> and is_enable = #{isEnable}</if>
            <if test="keyWord != null "> and type_name like concat('%', #{keyWord}, '%')</if>
    </select>



</mapper>
