| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.study.domain.*; |
| | | import com.ruoyi.study.dto.StudyWeekDTO; |
| | |
| | | import com.ruoyi.study.service.ITStudyService; |
| | | import com.ruoyi.study.service.ITSubjectService; |
| | | import com.ruoyi.study.service.ITUserStudyService; |
| | | import com.ruoyi.study.vo.*; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId).eq(TGameRecord::getGameId, game.getId()).list(); |
| | | boolean contains = list.stream().map(TGameRecord::getGameDifficulty).collect(Collectors.toList()).contains(level); |
| | | if (!contains) { |
| | | throw new GlobalException("请先完成上一难度再挑战"); |
| | | throw new GlobalException("请先完成上一难度再挑战当前难度!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> listenSelectPicture(Integer week, Integer day, List<TStudyListen> studyListens) { |
| | | public StudyListenResultVO listenSelectPicture(Integer week, Integer day, List<TStudyListen> studyListens) { |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyListen data = studyListens.get(rand.nextInt(studyListens.size())); |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | Map<String, Object> result = new HashMap<>(8); |
| | | result.put("data", data); |
| | | result.put("subject", subjectList); |
| | | return result; |
| | | return new StudyListenResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> pictureSelectVoice(Integer week, Integer day, List<TStudyLook> lookList) { |
| | | public StudyLookResultVO pictureSelectVoice(Integer week, Integer day, List<TStudyLook> lookList) { |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyLook data = lookList.get(rand.nextInt(lookList.size())); |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | Map<String, Object> result = new HashMap<>(8); |
| | | result.put("data", data); |
| | | result.put("subject", subjectList); |
| | | return result; |
| | | return new StudyLookResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> induceExclude(Integer week, Integer day, List<TStudyInduction> inductionList) { |
| | | public StudyInductionResultVO induceExclude(Integer week, Integer day, List<TStudyInduction> inductionList) { |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyInduction data = inductionList.get(rand.nextInt(inductionList.size())); |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | Map<String, Object> result = new HashMap<>(8); |
| | | result.put("data", data); |
| | | result.put("subject", subjectList); |
| | | return result; |
| | | return new StudyInductionResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> questionsAndAnswers(Integer week, Integer day, List<TStudyAnswer> answerList) { |
| | | public StudyAnswerResultVO questionsAndAnswers(Integer week, Integer day, List<TStudyAnswer> answerList) { |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyAnswer data = answerList.get(rand.nextInt(answerList.size())); |
| | | AnswerVO one = new AnswerVO(); |
| | | BeanUtils.copyProperties(data, one); |
| | | answerList.remove(data); |
| | | TStudyAnswer dataTwo = answerList.get(rand.nextInt(answerList.size())); |
| | | AnswerVO two = new AnswerVO(); |
| | | BeanUtils.copyProperties(dataTwo, two); |
| | | // 获取问题题目 和 回答题目 |
| | | Map<String, Object> result = new HashMap<>(8); |
| | | result.put("data", data); |
| | | // todo 有问有答 |
| | | return result; |
| | | List<String> ids = new ArrayList<>(); |
| | | ids.add(String.valueOf(one.getSubject())); |
| | | ids.add(String.valueOf(one.getAnswerSubject())); |
| | | // 有问有答 |
| | | List<TStudyAnswer> answers = new ArrayList<>(); |
| | | answers.add(one); |
| | | one.setSubjectList(getSubjects(ids.toArray(new String[0]))); |
| | | // 第二题信息 |
| | | List<String> twoIds = new ArrayList<>(); |
| | | answers.add(two); |
| | | twoIds.add(String.valueOf(two.getSubject())); |
| | | twoIds.add(String.valueOf(two.getAnswerSubject())); |
| | | two.setSubjectList(getSubjects(twoIds.toArray(new String[0]))); |
| | | return new StudyAnswerResultVO(answers); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> pictureMateVoice(Integer week, Integer day, TStudyPair pair) { |
| | | public StudyPairResultVO pictureMateVoice(Integer week, Integer day, TStudyPair pair) { |
| | | List<TSubject> subjectList = getSubjects(pair.getSubject().split(",")); |
| | | Map<String, Object> result = new HashMap<>(8); |
| | | result.put("data", pair); |
| | | result.put("subject", subjectList); |
| | | return result; |
| | | return new StudyPairResultVO(pair, subjectList); |
| | | } |
| | | |
| | | /** |