<?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.template.mapper.SmartEnrollmentUserMapper">

    <select id="listPage" resultType="com.template.model.vo.SmartEnrollmentUserVo">
        SELECT
        seu.id,
        tg.`name` as timeGroupName,
        seu.`name`,
        seu.card_no as cardNo,
        seu.id_card as idCard,
        seu.sex_id as sexId,
        seu.head_image as headImage,
        sd.`name` as departmentName,
        si.`name` as identityName,
        sg.`name` as gradeName,
        sc.`name` as schoolClassName,
        seu.`status` as status,
        seu.remark,
        seu.create_time as createTime
        FROM
        `smart_enrollment_user` seu
        LEFT JOIN smart_time_group tg ON tg.id = seu.time_group_id
        LEFT JOIN smart_department sd ON sd.id = seu.department_id
        LEFT JOIN smart_identity si ON si.id = seu.identity_id
        LEFT JOIN smart_grade sg ON sg.id = seu.grade
        LEFT JOIN smart_class sc ON sc.id = seu.school_class
        WHERE
        seu.deleted=0
        and seu.identity_id=2
        <if test="status != null and status != ''">
            and seu.status = #{status}
        </if>

        <if test="grade != null and grade != ''">
            and seu.grade = #{grade}
        </if>

        <if test="schoolClass != null and schoolClass != ''">
            and seu.school_class = #{schoolClass}
        </if>

        <if test="keyWord != null and keyWord != ''">
            and seu.name like '%' #{keyWord} '%'
        </if>
        ORDER BY seu.create_time desc
    </select>

    <select id="getAffiliate" resultType="com.template.model.vo.SmartEnrollmentAffiliateVo">
        SELECT
            `name`,
            phone,
            ship,
            `status`
        FROM
            `smart_enrollment_user`
        WHERE
            FIND_IN_SET( #{id}, affiliate )
    </select>
    <select id="getJiaZhang" resultType="com.template.model.pojo.SmartEnrollmentUser">
        SELECT
            *
        FROM
            `smart_enrollment_user`
        WHERE
            FIND_IN_SET( #{userId}, affiliate )
            and deleted=0
    </select>

</mapper>
