<?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.teacher.mapper.WfHeadTeacherLeaveMapper">
    <select id="getListPage" parameterType="com.xjrsoft.module.teacher.dto.WfHeadTeacherLeavePageDto"
            resultType="com.xjrsoft.module.teacher.vo.WfHeadTeacherLeavePageVo">
        SELECT
        t.id,
        t.start_time,
        t.end_time,
        t.applicant_user_id,
        t.substitute_user_id,
        t1.name as applicantUserIdCN,
        t2.name as substituteUserIdCN,
        t3.name as leaveReason
        FROM wf_head_teacher_leave t
        LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
        LEFT JOIN xjr_user t2 ON (t2.id = t.substitute_user_id)
        LEFT JOIN xjr_dictionary_detail t3 ON (t3.code = t.leave_reason)
        WHERE t.delete_mark = 0
        <if test="dto.applicantUserIdCN != null and dto.applicantUserIdCN != ''">
            and t1.name LIKE CONCAT('%',#{dto.applicantUserIdCN},'%')
        </if>
        <if test="dto.startTime != null and dto.startTime != ''">
            and t.start_time &gt; #{dto.startTime}
        </if>
        <if test="dto.endTime != null and dto.endTime != ''">
            and t.end_time &lt; #{dto.endTime}
        </if>
        <if test="dto.substituteUserIdCN != null and dto.substituteUserIdCN != ''">
            and t1.name LIKE CONCAT('%',#{dto.substituteUserIdCN},'%')
        </if>
        order by t.id
    </select>

</mapper>