<?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.willalp.flow.mapper.HsFlowTaskMapper">

    <resultMap type="com.willalp.flow.domain.HsFlowTask" id="HsFlowTaskResult">
        <result property="id" column="id"/>
        <result property="taskName" column="task_name"/>
        <result property="examplesId" column="examples_id"/>
        <result property="baseId" column="base_id"/>
        <result property="isCandidate" column="is_candidate"/>
        <result property="operator" column="operator"/>
        <result property="initiator" column="initiator"/>
        <result property="isEnd" column="is_end"/>
        <result property="businessId" column="business_id"/>
        <result property="msgIsRead" column="msg_is_read"/>
        <result property="isDelete" column="is_delete"/>
        <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="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsFlowTaskVo">
        select id,
               task_name,
               examples_id,
               base_id,
               is_candidate,
               initiator,
               operator,
               is_end,
               business_id,
               msg_is_read,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_flow_task
    </sql>

    <select id="selectHsFlowTaskList" parameterType="HsFlowTask" resultMap="HsFlowTaskResult">
        <include refid="selectHsFlowTaskVo"/>
        <where>
            is_delete = 0
            <if test="taskName != null  and taskName != ''">
                and task_name like concat('%', #{taskName}, '%')
            </if>
            <if test="examplesId != null  and examplesId != ''">
                and examples_id = #{examplesId}
            </if>
            <if test="baseId != null  and baseId != ''">
                and base_id = #{baseId}
            </if>
            <if test="initiator != null  and initiator != ''">
                and initiator = #{initiator}
            </if>
            <if test="businessId != null  and businessId != ''">
                and business_id = #{businessId}
            </if>
        </where>
    </select>
    <select id="selectAllByUserCode" resultType="com.willalp.flow.domain.HsFlowTask">
        <include refid="selectHsFlowTaskVo"/>
        <where>
            is_delete = 0
            AND is_end = '0'
            AND operator = #{userCode}
        </where>
        group by create_time desc
    </select>
    <select id="getDone" resultType="com.willalp.flow.domain.HsFlowTask">
        <include refid="selectHsFlowTaskVo"/>
        <where>
            is_delete = 0
            AND is_end = '1'
            AND operator = #{userCode}
        </where>
        group by create_time desc
    </select>
</mapper>
