<?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.hw.system.common.mapper.WfProcessMapper">

    <resultMap type="WfProcess" id="WfProcessResult">
        <result property="wfProcessId"    column="wf_process_id"    />
        <result property="wfProcessName"    column="wf_process_name"    />
        <result property="wfProcessType"    column="wf_process_type"    />
        <result property="remark"    column="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"    />
        <result property="timeLimit"    column="time_limit"    />
        <result property="processStatus"    column="process_status"    />
    </resultMap>

    <sql id="selectWfProcessVo">
        select wf_process_id, wf_process_name, wf_process_type, remark, create_by, create_time, update_by, update_time, time_limit, process_status from wf_process
    </sql>

    <select id="selectWfProcessList" parameterType="WfProcess" resultMap="WfProcessResult">
        <include refid="selectWfProcessVo"/>
        <where>
            <if test="wfProcessName != null  and wfProcessName != ''"> and wf_process_name like concat('%', #{wfProcessName}, '%')</if>
            <if test="wfProcessType != null  and wfProcessType != ''"> and wf_process_type = #{wfProcessType}</if>
            <if test="timeLimit != null "> and time_limit = #{timeLimit}</if>
            <if test="processStatus != null  and processStatus != ''"> and process_status = #{processStatus}</if>
        </where>
    </select>

    <select id="selectWfProcessByWfProcessId" parameterType="Long" resultMap="WfProcessResult">
        <include refid="selectWfProcessVo"/>
        where wf_process_id = #{wfProcessId}
    </select>

    <insert id="insertWfProcess" parameterType="WfProcess" useGeneratedKeys="true" keyProperty="wfProcessId">
        insert into wf_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wfProcessName != null and wfProcessName != ''">wf_process_name,</if>
            <if test="wfProcessType != null and wfProcessType != ''">wf_process_type,</if>
            <if test="remark != null">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>
            <if test="timeLimit != null">time_limit,</if>
            <if test="processStatus != null and processStatus != ''">process_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wfProcessName != null and wfProcessName != ''">#{wfProcessName},</if>
            <if test="wfProcessType != null and wfProcessType != ''">#{wfProcessType},</if>
            <if test="remark != null">#{remark},</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="timeLimit != null">#{timeLimit},</if>
            <if test="processStatus != null and processStatus != ''">#{processStatus},</if>
         </trim>
    </insert>

    <update id="updateWfProcess" parameterType="WfProcess">
        update wf_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="wfProcessName != null and wfProcessName != ''">wf_process_name = #{wfProcessName},</if>
            <if test="wfProcessType != null and wfProcessType != ''">wf_process_type = #{wfProcessType},</if>
            <if test="remark != null">remark = #{remark},</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="timeLimit != null">time_limit = #{timeLimit},</if>
            <if test="processStatus != null and processStatus != ''">process_status = #{processStatus},</if>
        </trim>
        where wf_process_id = #{wfProcessId}
    </update>

    <delete id="deleteWfProcessByWfProcessId" parameterType="Long">
        delete from wf_process where wf_process_id = #{wfProcessId}
    </delete>

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