浏览代码

抽问抽答如果未作答,仍返回题目的正确选项

simonlll 2 月之前
父节点
当前提交
3252eeac93

+ 2 - 6
airport-exam/src/main/java/com/sundot/airport/exam/controller/DailyTaskAdminController.java

@@ -160,12 +160,8 @@ public class DailyTaskAdminController extends BaseController {
160 160
                     .collect(Collectors.toList());
161 161
 
162 162
             if (!quesIds.isEmpty()) {
163
-                // 查询这些题目的选项
164
-                LambdaQueryWrapper<QuesOpt> optWrapper = new LambdaQueryWrapper<>();
165
-                optWrapper.in(QuesOpt::getQuId, quesIds);
166
-                optWrapper.eq(QuesOpt::getDelStatus, 0);
167
-                optWrapper.orderByAsc(QuesOpt::getSort);
168
-                List<QuesOpt> allOptions = quesOptMapper.selectList(optWrapper);
163
+                // 查询这些题目的选项(使用自定义方法,忽略逻辑删除条件)
164
+                List<QuesOpt> allOptions = quesOptMapper.selectByQuesIds(quesIds);
169 165
 
170 166
                 // 按题目ID分组
171 167
                 for (QuesOpt opt : allOptions) {

+ 16 - 0
airport-exam/src/main/java/com/sundot/airport/exam/mapper/QuesOptMapper.java

@@ -3,6 +3,10 @@ package com.sundot.airport.exam.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.sundot.airport.exam.domain.QuesOpt;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
8
+
9
+import java.util.List;
6 10
 
7 11
 
8 12
 /**
@@ -16,4 +20,16 @@ import org.apache.ibatis.annotations.Mapper;
16 20
 @Mapper
17 21
 public interface QuesOptMapper extends BaseMapper<QuesOpt> {
18 22
 
23
+    /**
24
+     * 根据题目ID列表查询选项(忽略逻辑删除)
25
+     */
26
+    @Select("<script>" +
27
+            "SELECT * FROM edu_cs_ques_opt WHERE qu_id IN " +
28
+            "<foreach collection='quesIds' item='id' open='(' separator=',' close=')'>" +
29
+            "#{id}" +
30
+            "</foreach>" +
31
+            " ORDER BY sort" +
32
+            "</script>")
33
+    List<QuesOpt> selectByQuesIds(@Param("quesIds") List<String> quesIds);
34
+
19 35
 }