|
|
|
@ -2,6 +2,7 @@ package com.wrj.driver.server.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.wrj.driver.server.constant.Constants; |
|
|
|
|
import com.wrj.driver.server.dto.QuestionPracticeAddDto; |
|
|
|
|
import com.wrj.driver.server.entity.WrjQuestion; |
|
|
|
|
import com.wrj.driver.server.entity.WrjQuestionPractice; |
|
|
|
@ -51,16 +52,17 @@ public class WrjQuestionPracticeServiceImpl extends ServiceImpl<WrjQuestionPract |
|
|
|
|
if (question == null) { |
|
|
|
|
throw new BusinessException("题目不存在"); |
|
|
|
|
} |
|
|
|
|
boolean isTrue = StrUtil.equals(addDto.getAnswer(), question.getTrueAnswer()); |
|
|
|
|
|
|
|
|
|
WrjQuestionPractice questionPractice = new WrjQuestionPractice(); |
|
|
|
|
BeanUtil.copyProperties(addDto, questionPractice); |
|
|
|
|
|
|
|
|
|
// 插入练习
|
|
|
|
|
questionPractice.setPracticeTime(LocalDateTime.now()); |
|
|
|
|
questionPractice.setAnswerResult(isTrue? Constants.STR_ONE : Constants.STR_TWO); |
|
|
|
|
practiceMapper.insert(questionPractice); |
|
|
|
|
|
|
|
|
|
// 判断答题是否正确
|
|
|
|
|
boolean isTrue = StrUtil.equals(addDto.getAnswer(), question.getTrueAnswer()); |
|
|
|
|
|
|
|
|
|
questionMapper.updateAnswerNumber(addDto.getQuestionId(), 1, (isTrue ? 1 : 0)); |
|
|
|
|
|
|
|
|
@ -89,7 +91,6 @@ public class WrjQuestionPracticeServiceImpl extends ServiceImpl<WrjQuestionPract |
|
|
|
|
practiceTotalMapper.updateAnswerNumber(addDto.getUserId(), addDto.getQuestionId(), 1, (isTrue ? 1 : 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Boolean.TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|