<?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.qmth.distributed.print.business.mapper.GradePaperDimensionMapper">

    <select id="findGradePaperDimensionList"
            resultType="com.qmth.distributed.print.business.bean.result.analyze.GradePaperDimensionResult">
        SELECT
            et.course_code AS courseCode,
            et.course_name AS courseName,
            gpd.dimension_type AS dimensionType,
            gpd.code_primary AS codePrimary,
            gpd.name_primary AS namePrimary,
            gpd.code_second AS codeSecond,
            gpd.name_second AS nameSecond,
            gpd.interpretation AS interpretation
        FROM
            grade_paper_dimension gpd
                LEFT JOIN
            exam_task et ON gpd.school_id = et.school_id
                AND gpd.paper_number = et.paper_number
        <where>
            <if test="schoolId != null and schoolId != ''">
                AND gpd.school_id = #{schoolId}
            </if>
            <if test="paperNumber != null and paperNumber != ''">
                AND gpd.paper_number = #{paperNumber}
            </if>
            <if test="paperType != null and paperType != ''">
                AND gpd.paper_type = #{paperType}
            </if>
        </where>
    </select>
    <select id="findBySchoolIdAndPaperNumberAndPaperType"
            resultType="com.qmth.distributed.print.business.bean.dto.open.PaperDimension">
        SELECT id,
               paper_number   paperNumber,
               paper_name     paperName,
               dimension_type dimensionType,
               code_primary   codePrimary,
               name_primary   namePrimary,
               code_second    codeSecond,
               name_second    nameSecond,
               interpretation
        FROM grade_paper_dimension
        where school_id = #{schoolId}
          and paper_number = #{paperNumber}
          and paper_type = #{paperType}
    </select>

</mapper>
