Commit 2051ae55 authored by 陈立彬's avatar 陈立彬

fix

parent 2f767039
......@@ -42,11 +42,12 @@ public class ExamController {
@GetMapping(value = "/get_question")
public ApiResponse<ElehKnowledgeDo> getQuestion(@RequestParam("tenant") Integer tenant,
@RequestParam("code") String code,
@RequestParam("session_id") String sessionId) {
@RequestParam("session_id") String sessionId,
@RequestParam("user_id") String userId) {
ElehKnowledgeTagDo tagDo = tagMapper.selectByCode(tenant, code);
Long maxQuestionId = qaRecordMapper.selectSessionMaxQuestionId(tenant, sessionId);
Long maxQuestionId = qaRecordMapper.selectSessionMaxQuestionId(tenant, sessionId, userId);
maxQuestionId = Objects.nonNull(maxQuestionId) ? maxQuestionId : 0;
ElehKnowledgeDo knowledgeDo = knowledgeMapper.selectQuestion(tenant, tagDo.getId(), maxQuestionId);
return ApiResponse.ok(knowledgeDo);
......@@ -78,13 +79,15 @@ public class ExamController {
@GetMapping(value = "/get_final_result")
public ApiResponse<Double> getFinalResult(@RequestParam("tenant") Integer tenant,
@RequestParam("session_id") String sessionId) {
@RequestParam("session_id") String sessionId,
@RequestParam("user_id") String userId) {
Double avgScore = 0D;
LambdaQueryWrapper<ElehSessionQaRecordDo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ElehSessionQaRecordDo::getTenant, tenant);
queryWrapper.eq(ElehSessionQaRecordDo::getSessionId, sessionId);
queryWrapper.eq(ElehSessionQaRecordDo::getUserId, userId);
List<ElehSessionQaRecordDo> qaRecordDos = qaRecordMapper.selectList(queryWrapper);
if(!CollectionUtils.isEmpty(qaRecordDos)) {
double sum = qaRecordDos.stream().mapToDouble(ElehSessionQaRecordDo::getScore).sum();
......
......@@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Select;
public interface ElehSessionQaRecordMapper extends BaseMapper<ElehSessionQaRecordDo> {
@Select(value = "select max(question_id) from eleh_session_qa_record where tenant = #{tenant} and session_id = #{sessionId}")
Long selectSessionMaxQuestionId(@Param("tenant") Integer tenant, @Param("sessionId") String sessionId);
@Select(value = "select max(question_id) from eleh_session_qa_record where tenant = #{tenant} and session_id = #{sessionId} and user_id = #{userId}")
Long selectSessionMaxQuestionId(@Param("tenant") Integer tenant, @Param("sessionId") String sessionId, @Param("userId") String userId);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment