<?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.yida.data.school.smart.mapper.EduSmartWelcomeGuideRosterMapper">

  <!-- 查询指南花名册分页列表 -->
  <select id="listGuideRoster" resultType="com.yida.data.school.vo.smart.GuideRosterSelectPageVO">
    SELECT
    DISTINCT
    a.id as roster_id,
    a.graduate_school,
    a.full_name,
    a.id_number,
    a.admitted_major,
    a.qr_code_url,
    a.create_date,
    a.registration_status,
    a.dormitory,
    a.dormitory_room,
    a.campus_name,
    a.section_name,
    a.grade_name,
    a.class_name
    FROM
    edu_smart_welcome_guide_roster a
    WHERE
    a.del_flag = 0
    AND a.guide_id = #{dto.guideId}
      <if test="dto.passRosterIdList != null and dto.passRosterIdList.size() > 0">
        AND a.id IN
        <foreach collection="dto.passRosterIdList" item="item" close=")" open="(" separator=",">
          #{item}
        </foreach>
      </if>
      <if test='dto.payStatus != null '>
        AND a.pay_status = #{dto.payStatus}
      </if>
      <if test='dto.graduateSchool != null and dto.graduateSchool != ""'>
        AND a.graduate_school LIKE CONCAT( '%', #{dto.graduateSchool}, '%' )
      </if>
      <if test='dto.fullName != null and dto.fullName != ""'>
        AND a.full_name LIKE CONCAT( '%', #{dto.fullName}, '%' )
      </if>
      <if test='dto.idNumber != null and dto.idNumber != ""'>
        AND a.id_number LIKE CONCAT( '%', #{dto.idNumber}, '%' )
      </if>
      <if test='dto.admittedMajor != null and dto.admittedMajor != ""'>
        AND a.admitted_major LIKE CONCAT( '%', #{dto.admittedMajor}, '%' )
      </if>
      <if test='dto.registrationStatus != null'>
        AND a.registration_status = #{dto.registrationStatus}
      </if>
    ORDER BY
    a.create_date DESC
  </select>

</mapper>
