<?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.textbook.mapper.WfTextbookClaimMapper">
    <select id="getPage" parameterType="com.xjrsoft.module.textbook.dto.WfTextbookClaimPageDto"
            resultType="com.xjrsoft.module.textbook.vo.WfTextbookClaimPageVo">
        SELECT
            t.*,
            t1.name as applicantUserIdCN,
            t2.name as classIdCN,
            t3.name as baseSemesterIdCN,
            t4.name as studentUserIdCN,
            t5.name as claimTypeCN,
            t6.user_id,
            t7.name as claimUserIdCN
        FROM wf_textbook_claim t
                 LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
                 LEFT JOIN base_class t2 ON (t2.id = t.class_id)
                 LEFT JOIN base_semester t3 ON (t3.id = t.base_semester_id)
                 LEFT JOIN xjr_user t4 ON (t4.id = t.student_user_id)
                 LEFT JOIN xjr_dictionary_detail t5 ON (t5.code = t.claim_type)
                 LEFT JOIN textbook_claim_user t6 ON (t6.wf_textbook_claim_id = t.id)
                 LEFT JOIN xjr_user t7 ON (t7.id = t6.user_id)
        WHERE t.delete_mark = 0 and t6.user_id = #{dto.userId}
        order by t.create_date desc;
    </select>

    <select id="infoDistribute" parameterType="java.lang.Long"
            resultType="com.xjrsoft.module.textbook.vo.WfTextbookClaimVo">
        SELECT
            t.*,
            t1.name as applicantUserIdCN,
            t2.name as classIdCN,
            t3.name as baseSemesterIdCN,
            t4.name as studentUserIdCN,
            t5.name as claimTypeCN,
            t7.name as claimUserIdCN
        FROM wf_textbook_claim t
                 LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
                 LEFT JOIN base_class t2 ON (t2.id = t.class_id)
                 LEFT JOIN base_semester t3 ON (t3.id = t.base_semester_id)
                 LEFT JOIN xjr_user t4 ON (t4.id = t.student_user_id)
                 LEFT JOIN xjr_dictionary_detail t5 ON (t5.code = t.claim_type)
                 LEFT JOIN textbook_claim_user t6 ON (t6.id = t.claim_user_id)
                 LEFT JOIN xjr_user t7 ON (t7.id = t6.user_id)
        WHERE t.delete_mark = 0 and t.id = #{id}
        order by t.id;
    </select>
</mapper>