<?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.xjrsoft.module.student.mapper.SchoolRollFurtherEducationMapper">
    <select id="getPageListPc" parameterType="com.xjrsoft.module.student.dto.SchoolRollFurtherEducationPageDto"
            resultType="com.xjrsoft.module.student.vo.SchoolRollFurtherEducationPageVo">
        SELECT
            t.id,
            t.sort_code,
            t.student_id AS studentId,
            t1.name AS studentIdCN,
            t1.credential_number AS credentialNumber,
            t2.name AS beforeMajorSetIdCN,
            t3.name AS beforeClassIdCN,
            t4.name AS backClassIdCN,
            t5.name AS backMajorSetIdCN,
            t6.name AS applicantUserIdCN,
            t.reason,
            t.enabled_mark AS enabledMark,
            t.status
        FROM school_roll_further_education t
                 LEFT JOIN xjr_user t1 ON (t.student_id = t1.id)
                 LEFT JOIN base_major_set t2 ON (t.before_major_set_id = t2.id)
                 LEFT JOIN base_class t3 ON (t.before_class_id = t3.id)
                 LEFT JOIN base_class t4 ON (t.back_class_id = t4.id)
                 LEFT JOIN base_major_set t5 ON (t.back_major_set_id = t5.id)
                 LEFT JOIN xjr_user t6 ON (t.applicant_user_id = t6.id)
        WHERE t.delete_mark = 0 AND t.status = 1
        <if test="dto.studentIdCN != null and dto.studentIdCN != ''">
            and t1.name like concat('%',#{dto.studentIdCN},'%')
        </if>
        <if test="dto.beforeClassIdCN != null and dto.beforeClassIdCN != ''">
            and t3.name like concat('%',#{dto.beforeClassIdCN},'%')
        </if>
        <if test="dto.backClassIdCN != null and dto.backClassIdCN != ''">
            and t4.name like concat('%',#{dto.backClassIdCN},'%')
        </if>
        <if test="dto.applicantUserIdCN != null and dto.applicantUserIdCN != ''">
            and t6.name like concat('%',#{dto.applicantUserIdCN},'%')
        </if>
        ORDER BY t.id DESC;
    </select>

    <select id="getDetailById"
            resultType="com.xjrsoft.module.student.vo.SchoolRollFurtherEducationVo">
        SELECT
            t.*,
            t1.name AS studentIdCN,
            t1.credential_number AS credentialNumber,
            t2.name AS beforeMajorSetIdCN,
            t3.name AS beforeClassIdCN,
            t4.name AS backClassIdCN,
            t5.name AS backMajorSetIdCN,
            t6.name AS applicantUserIdCN
        FROM school_roll_further_education t
                 LEFT JOIN xjr_user t1 ON (t.student_id = t1.id)
                 LEFT JOIN base_major_set t2 ON (t.before_major_set_id = t2.id)
                 LEFT JOIN base_class t3 ON (t.before_class_id = t3.id)
                 LEFT JOIN base_class t4 ON (t.back_class_id = t4.id)
                 LEFT JOIN base_major_set t5 ON (t.back_major_set_id = t5.id)
                 LEFT JOIN xjr_user t6 ON (t.applicant_user_id = t6.id)
        WHERE t.id = #{id} AND t.delete_mark = 0 AND t.status = 1;
    </select>
</mapper>