<?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.yiqing.mapper.HsTaskBelongUserMapper">

    <resultMap type="com.willalp.yiqing.domain.HsTaskBelongUser" id="HsTaskBelongUserResult">
        <result property="taskBelongId" column="task_belong_id"/>
        <result property="yqTaskId" column="yq_task_id"/>
        <result property="belongUserNo" column="belong_user_no"/>
        <result property="nickName" column="nick_name"/>
        <result property="belongLevel" column="belong_level"/>
        <result property="msgIsRead" column="msg_is_read"/>
        <result property="isOrder" column="is_order"/>
        <result property="userTaskStatus" column="user_task_status"/>
        <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="selectHsTaskBelongUserVo">
        select task_belong_id,
               yq_task_id,
               belong_user_no,
               nick_name,
               belong_level,
               msg_is_read,
               is_order,
               user_task_status,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_task_belong_user
    </sql>

    <select id="selectHsTaskBelongUserList" resultMap="HsTaskBelongUserResult">
        <include refid="selectHsTaskBelongUserVo"/>
        <where>
            is_delete = 0
            <if test="yqTaskId != null ">
                  and yq_task_id = #{yqTaskId}
            </if>
            <if test="belongUserNo != null ">
                  and belong_user_no like concat('%', #{belongUserNo}, '%')
            </if>
            <if test="nickName != null  and nickName != ''">
                  and nick_name like concat('%', #{nickName}, '%')
            </if>
            <if test="belongLevel != null ">
                  and belong_level = #{belongLevel}
            </if>
            <if test="isDelete != null ">
                  and is_delete = #{isDelete}
            </if>
        </where>
        ORDER BY belong_level
    </select>
</mapper>
