<?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.CourseWeightMapper">

    <select id="findCourseWeightForm"
            resultType="com.qmth.distributed.print.business.bean.dto.CourseWeightFormDto">
        SELECT
            ct.id AS targetId,
            ct.target_name AS targetName,
            ct.create_time AS targetCreateTime,
            cw.target_score AS targetScore,
            ce.id AS evaluationId,
            ce.evaluation AS evaluation,
            ce.evaluation_desc AS evaluationDesc,
            ce.create_time AS evaluationCreateTime,
            ce.type AS type
        FROM
            course_weight cw
                LEFT JOIN
            course_target ct ON cw.target_id = ct.id
                LEFT JOIN
            course_evaluation ce ON cw.evaluation_id = ce.id
        <where>
            AND cw.enable
            <if test="teachCourseId != null">
                AND cw.teach_course_id = #{teachCourseId}
            </if>
        </where>
        ORDER BY ct.id,ce.id
    </select>
</mapper>
