<?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.HsFlowCcMapper">

    <resultMap type="com.willalp.flow.domain.HsFlowCc" id="HsFlowCcResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="formData" column="form_data"/>
        <result property="taskId" column="task_id"/>
        <result property="users" column="users"/>
        <result property="isDelete" column="is_delete"/>
        <result property="examplesId" column="examples_id"/>
        <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="selectHsFlowCcVo">
        select id,
               title,
               form_data,
               task_id,
               users,
               is_delete,
               examples_id,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_flow_cc
    </sql>

    <select id="selectHsFlowCcList" parameterType="HsFlowCc" resultMap="HsFlowCcResult">
        <include refid="selectHsFlowCcVo"/>
        <where>
            is_delete = 0
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="jsonData != null  and jsonData != ''">
                and json_data = #{jsonData}
            </if>
            <if test="taskId != null  and taskId != ''">
                and task_id = #{taskId}
            </if>
            <if test="users != null  and users != ''">
                and users = #{users}
            </if>
            <if test="examplesId != null  and examplesId != ''">
                and examples_id = #{examplesId}
            </if>
        </where>
        order by update_time desc
    </select>
    <select id="appGetCcRecordList" resultType="com.willalp.flow.domain.HsFlowCc">
        select id,
        title,
        form_data,
        task_id,
        users,
        is_delete,
        examples_id,
        create_by,
        create_time,
        remark,
        (SELECT msg_is_read FROM hs_app_user_msg where remark = hfc.task_id AND msg_is_read = '0' limit 1) msg_is_read
        from hs_flow_cc hfc
        <where>
            is_delete = 0
            AND locate(#{uc},users)
            order by update_time desc
        </where>
    </select>
</mapper>
