<?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.WfCadreCandidateMapper">
    <select id="getListPage" parameterType="com.xjrsoft.module.student.dto.WfCadreCandidatePageDto"
            resultType="com.xjrsoft.module.student.vo.WfCadreCandidatePageVo">
        SELECT
            t.*,
            t1.name as applicantUserIdCN,
            t2.name as cadreDeptIdCN,
            t3.name as instructorUserIdCN
        FROM wf_cadre_candidate t
                 LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
                 LEFT JOIN cadre_dept t2 ON (t2.id = t.cadre_dept_id)
                 LEFT JOIN xjr_user t3 ON (t3.id = t.instructor_user_id)
        WHERE t.delete_mark = 0
        <if test="dto.cadreDeptId != null and dto.cadreDeptId > 0">
            and t.cadre_dept_id = #{dto.cadreDeptId}
        </if>
        <if test="dto.applicantUserIdCN != null and dto.applicantUserIdCN != ''">
            and t1.name like concat('%',#{dto.applicantUserIdCN},'%')
        </if>
        <if test="dto.studentId != null and dto.studentId != ''">
            and t.student_id = #{dto.studentId}
        </if>
        order by t.id
    </select>
</mapper>