SubjectTestPublishHistoryMapper.xml 7.28 KB
<?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.meishu.mapper.SubjectTestPublishHistoryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.meishu.model.SubjectTestPublishHistoryDO">
        <id column="id" property="id"/>
        <result column="create_date" property="createTime"/>
        <result column="update_date" property="updateTime"/>
        <result column="delete_date" property="deleteTime"/>
        <!--        <result column="rule_id" property="ruleId" />-->
        <!--        <result column="deadline" property="deadline" />-->
        <!--        <result column="outline" property="outline" />-->
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, rule_id, deadline, outline
    </sql>


    <select id="getStudentExamination"
            resultType="com.meishu.vo.rule.GetStudentRulesVO">
              SELECT
            t.id,
            t2.rule_name,
            t.outline,
            t5.create_date,
            t.test_time,
            t4.examination,
            t3.subject_name,
            t.cover_page,
            t.test_type,
            t.publish_name
        FROM
            subject_test_student_answer t5
            LEFT JOIN subject_test_publish_history t ON t5.publish_id = t.id
            LEFT JOIN subject_test_dict t4 ON t.test_id = t4.id
            LEFT JOIN subject_rule t2 ON t4.rule_id = t2.id
            LEFT JOIN knowledge_subject_dict t3 ON t2.subject_id = t3.id
            left join student t6 on t5.student_id = t6.id
        WHERE
            t5.student_id = #{id}
            <if test="subjectId!=null and subjectId!=''">
                and t2.subject_id = #{subjectId}
            </if>
            and t6.status = 1
            AND t.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t5.delete_date IS NULL
    </select>

    <select id="getOneExaminationDetail" parameterType="com.meishu.model.SubjectTestStudentAnswerDO"
            resultType="com.meishu.vo.rule.GetOneExaminationDetailVO">
         SELECT
            t2.id,
            t4.subject_name,
            t3.rule_name,
            t5.examination,
            t2.answer,
            t1.test_time ,
            t1.publish_name,
            t1.test_type,
            t2.create_date as commitTime
        FROM
            subject_test_publish_history t1
            LEFT JOIN subject_test_student_answer t2 ON t1.id = t2.publish_id
            left join subject_test_dict t5 on t1.test_id = t5.id
            LEFT JOIN subject_rule t3 ON t5.rule_id = t3.id
            LEFT JOIN knowledge_subject_dict t4 ON t3.subject_id = t4.id
        WHERE
            t2.student_id = #{studentId} and t1.id = #{publishId}
            AND t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            and t5.delete_date is null
    </select>

    <select id="studentStar" parameterType="com.meishu.model.SubjectTestStudentAnswerDO"
            resultType="com.meishu.vo.rule.StudentStarVO">
        SELECT
            t3.dimension,
            t2.star,
            t2.description,
            t4.user_name
        FROM
            subject_student_answer_star t
            LEFT JOIN subject_dimension_star_dict t2 ON t.star_id = t2.id
            LEFT JOIN subject_dimension_dict t3 ON t2.dimension_id = t3.id
            LEFT JOIN administer t4 ON t.administer_id = t4.id
        WHERE
            t.publish_id = #{publishId}
            AND t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
    </select>

    <select id="getTestReport" resultType="com.meishu.vo.test.GetTestReportVO">
        SELECT
        t.id,
        t.publish_name,
        t3.rule_name,
        t2.test_name,
        t.test_time,
        t4.to_cnt,
        t5.done_cnt
        FROM
        subject_test_publish_history t
        LEFT JOIN subject_test_dict t2 ON t.test_id = t2.id
        LEFT JOIN subject_rule t3 ON t2.rule_id = t3.id
        LEFT JOIN ( SELECT t.publish_id, count( 1 ) AS to_cnt FROM subject_test_student_answer t WHERE t.`commit_status` = 1 GROUP BY t.publish_id ) t4 ON t.id = t4.publish_id
        LEFT JOIN ( SELECT t.publish_id, count( 1 ) AS done_cnt FROM subject_test_student_answer t WHERE t.`commit_status` = 0 GROUP BY t.publish_id ) t5 ON t.id = t5.publish_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
        <if test="ruleId !=null and ruleId != ''">
            AND t3.id = #{ruleId}
        </if>
        <if test="publishName!=null and publishName!=''">
            and t.publish_name = #{publishName}
        </if>
    </select>

    <select id="getPublishHistory"  resultType="com.meishu.vo.test.GetPublishHistoryVO">
        SELECT
            t.id,
            t2.id as testId,
            t.publish_name,
            t3.rule_name,
            t.test_time,
            t2.test_name,
            t2.examination,
            t.outline,
            t.cover_page
        FROM
            subject_test_publish_history t
            LEFT JOIN subject_test_dict t2 ON t.test_id = t2.id
            LEFT JOIN subject_rule t3 ON t2.rule_id = t3.id
        WHERE
            t.delete_date IS NULL
            <if test="ruleId != null and ruleId !=''">
                and t3.id = #{ruleId}
            </if>
            <if test="publishName!=null and publishName !=''">
                and t.publish_name = #{publishName}
            </if>
    </select>

    <select id="getOnePublish" resultType="com.meishu.vo.test.GetOnePublishVO">
        SELECT
            t.id,
            t.student_id,
            t.publish_id,
            t2.username,
            t.answer,
            t.comment_status
        FROM
            subject_test_student_answer t
            LEFT JOIN student t2 ON t.student_id = t2.id
            LEFT JOIN campus_dict t3 ON t2.campus_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            <if test="id !=null and id !=''">
                AND t.publish_id = #{id}
            </if>
            <if test="commentStatus!=null and commentStatus!=''">
                AND t.comment_status = #{commentStatus}
            </if>
            <if test="userName!=null and userName!=''">
                and t2.user_name = #{userName}
            </if>
    </select>

    <select id="getCommentDetail" parameterType="com.meishu.vo.test.GetOnePublishVO" resultType="com.meishu.vo.test.CommentVO">
        SELECT
            t2.user_name,
            t3.dimension,
            t4.star
        FROM
            subject_student_answer_star t
            LEFT JOIN administer t2 ON t.administer_id = t2.id
            LEFT JOIN subject_dimension_dict t3 ON t.administer_id = t3.id
            LEFT JOIN subject_dimension_star_dict t4 ON t.star_id = t4.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            and t.publish_id = #{publishId}
            and t.student_id = #{studentId}
    </select>
</mapper>