xiangpei
2024-05-22 73ff2a87258203049fc8d885709273eedfacd526
题目按课目导出
3个文件已修改
85 ■■■■■ 已修改文件
src/main/java/com/mindskip/xzs/controller/admin/QuestionController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/vo/QuestionExportVO.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QuestionMapper.xml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/controller/admin/QuestionController.java
@@ -197,9 +197,8 @@
                .doWrite(data);
    }
    @GetMapping("/question/export")
    public void importQuestion(QuestionExportVO query, HttpServletResponse response) throws IOException {
        query.formartTime();
    @PostMapping("/question/export")
    public void exportQuestion(@RequestBody QuestionExportVO query, HttpServletResponse response) throws IOException {
        // 查询导出数据
        List<QuestionImportVO> exportData = questionService.export(query);
        // 构建数据
src/main/java/com/mindskip/xzs/vo/QuestionExportVO.java
@@ -6,6 +6,7 @@
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
/**
 * @author:xp
@@ -15,29 +16,9 @@
public class QuestionExportVO {
    /**
     * 题型
     * 课目
     */
    private Integer questionType;
    private List<Integer> subjectIds;
    /**
     * 开始时间
     */
    private String startStr;
    private Date start;
    /**
     * 结束时间
     */
    private String endStr;
    private Date end;
    public void formartTime() {
        if (StringUtils.hasText(startStr)) {
            start = DateTimeUtil.parse(startStr, "yyyy-MM-dd HH:mm:ss");
        }
        if (StringUtils.hasText(endStr)) {
            end = DateTimeUtil.parse(endStr, "yyyy-MM-dd HH:mm:ss");
        }
    }
}
src/main/resources/mapper/QuestionMapper.xml
@@ -249,16 +249,18 @@
    <select id="export" resultMap="exportMap">
        SELECT
        DISTINCT
        q.*, ttc.content
        FROM
        t_question q
        INNER JOIN t_text_content ttc on q.info_text_content_id = ttc.id AND q.deleted = 0
        INNER JOIN t_question_subject tqs on q.id = tqs.question_id
        <where>
            <if test="query.questionType != null">
                q.question_type = #{query.questionType}
            </if>
            <if test="query.start != null and query.end != null">
                q.create_time between #{query.start} and #{query.end}
            <if test="query.subjectIds != null and query.subjectIds.size > 0">
                AND tqs.subject_id IN
                <foreach collection="query.subjectIds" open="(" separator="," close=")" item="subjectId">
                    #{subjectId}
                </foreach>
            </if>
        </where>
    </select>
@@ -284,20 +286,21 @@
    <select id="getVoByIds" resultType="com.mindskip.xzs.domain.vo.QuestionVO">
        SELECT
            tq.id,
            tq.question_type as questionType,
            tq.difficult,
            ttc.content as contentJson
        tq.id,
        tq.question_type as questionType,
        tq.difficult,
        ttc.content as contentJson
        FROM
            t_question tq
                INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.deleted = 0 AND tq.id IN
        t_question tq
        INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.deleted = 0 AND tq.id IN
        <foreach
                collection="ids" open="(" separator="," close=")" item="id">
            #{id}
        </foreach>
    </select>
    <select id="selectQuestion" resultType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM">
    <select id="selectQuestion"
            resultType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM">
        select a.id,
               a.question_type,
               JSON_VALUE(d.content, '$.titleContent') as shortTitle,
@@ -307,31 +310,27 @@
                 inner join t_subject c on b.subject_id = c.id and c.deleted = 0
                 inner join t_text_content d on a.info_text_content_id = d.id
        where a.deleted = 0
        AND JSON_VALUE(d.content, '$.titleContent') like concat('%', #{shortTitle}, '%')
          AND JSON_VALUE(d.content, '$.titleContent') like concat('%', #{shortTitle}, '%')
        group by a.id, question_type, a.create_time
        HAVING GROUP_CONCAT(c.name) like concat('%', #{subjectName}, '%')
        order by a.create_time
    </select>
    <select id="selectContentById" resultType="com.mindskip.xzs.domain.vo.QuestionVO">
        SELECT
            tq.id,
            tq.question_type as questionType,
            tq.difficult,
            ttc.content as contentJson,
            tq.correct
        FROM
            t_question tq
            INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.id = #{id}
        SELECT tq.id,
               tq.question_type as questionType,
               tq.difficult,
               ttc.content      as contentJson,
               tq.correct
        FROM t_question tq
                 INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.id = #{id}
    </select>
    <select id="getAnswer" resultType="com.mindskip.xzs.domain.vo.QuestionVO">
        SELECT
            tq.correct,
            ttc.content as contentJson
        FROM
            t_question tq
                INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.id = #{id} AND tq.deleted = 0
        SELECT tq.correct,
               ttc.content as contentJson
        FROM t_question tq
                 INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id AND tq.id = #{id} AND tq.deleted = 0
    </select>
</mapper>