| | |
| | | } |
| | | |
| | | @Override |
| | | public TUserStudy studySchedule(String userId, Integer week, Integer day) { |
| | | return userStudyService.studySchedule(userId, week, day); |
| | | public TUserStudy studySchedule(String userId, Integer week) { |
| | | return userStudyService.studySchedule(userId, week); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public StudyListenResultVO listenSelectPicture(Integer week, Integer day, List<TStudyListen> studyListens) { |
| | | if (studyListens.isEmpty()) { |
| | | throw new GlobalException("当前学习周目题目数量不足!"); |
| | | } |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyListen data = studyListens.get(rand.nextInt(studyListens.size())); |
| | | TStudyListen data; |
| | | if (studyListens.size() == 1) { |
| | | data = studyListens.get(0); |
| | | } else { |
| | | data = studyListens.get(rand.nextInt(studyListens.size())); |
| | | } |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | return new StudyListenResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public StudyLookResultVO pictureSelectVoice(Integer week, Integer day, List<TStudyLook> lookList) { |
| | | if (lookList.isEmpty()) { |
| | | throw new GlobalException("当前学习周目题目数量不足!"); |
| | | } |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyLook data = lookList.get(rand.nextInt(lookList.size())); |
| | | TStudyLook data; |
| | | if (lookList.size() == 1) { |
| | | data = lookList.get(0); |
| | | } else { |
| | | data = lookList.get(rand.nextInt(lookList.size())); |
| | | } |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | return new StudyLookResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public StudyInductionResultVO induceExclude(Integer week, Integer day, List<TStudyInduction> inductionList) { |
| | | if (inductionList.isEmpty()) { |
| | | throw new GlobalException("当前学习周目题目数量不足!"); |
| | | } |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyInduction data = inductionList.get(rand.nextInt(inductionList.size())); |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | TStudyInduction data; |
| | | if (inductionList.size() == 1) { |
| | | data = inductionList.get(0); |
| | | } else { |
| | | data = inductionList.get(rand.nextInt(inductionList.size())); |
| | | } |
| | | String[] ids = data.getSubject().split(","); |
| | | List<TSubject> subjectList = new ArrayList<>(); |
| | | for (String id : ids) { |
| | | if (id.startsWith("-")) { |
| | | id = id.replace("-", ""); |
| | | } |
| | | subjectList.add(subjectService.getById(id)); |
| | | } |
| | | return new StudyInductionResultVO(data, subjectList); |
| | | } |
| | | |
| | | @Override |
| | | public StudyAnswerResultVO questionsAndAnswers(Integer week, Integer day, List<TStudyAnswer> answerList) { |
| | | if (answerList.isEmpty()) { |
| | | throw new GlobalException("当前学习周目题目数量不足!"); |
| | | } |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyAnswer data = answerList.get(rand.nextInt(answerList.size())); |
| | | TStudyAnswer data; |
| | | TStudyAnswer dataTwo; |
| | | if (answerList.size() == 1) { |
| | | data = answerList.get(0); |
| | | dataTwo = answerList.get(0); |
| | | } else { |
| | | data = answerList.get(rand.nextInt(answerList.size())); |
| | | dataTwo = 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); |
| | | // 获取问题题目 和 回答题目 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public StudyPairResultVO pictureMateVoice(Integer week, Integer day, TStudyPair pair) { |
| | | List<TSubject> subjectList = getSubjects(pair.getSubject().split(",")); |
| | | return new StudyPairResultVO(pair, subjectList); |
| | | public StudyPairResultVO pictureMateVoice(Integer week, Integer day, List<TStudyPair> pair) { |
| | | if (pair.isEmpty()) { |
| | | throw new GlobalException("当前学习周目题目数量不足!"); |
| | | } |
| | | // 随机获取一组题 |
| | | Random rand = new Random(); |
| | | TStudyPair data; |
| | | if (pair.size() == 1) { |
| | | data = pair.get(0); |
| | | } else { |
| | | data = pair.get(rand.nextInt(pair.size())); |
| | | } |
| | | List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); |
| | | return new StudyPairResultVO(data, subjectList); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 图片及语音集合 |
| | | */ |
| | | private List<TSubject> getSubjects(String[] ids) { |
| | | return subjectService.lambdaQuery().in(TSubject::getId, Arrays.asList(ids)).list(); |
| | | List<TSubject> list = new ArrayList<>(); |
| | | for (String id : ids) { |
| | | TSubject data = subjectService.lambdaQuery().eq(TSubject::getId, id) |
| | | .eq(TSubject::getDisabled, 0).one(); |
| | | list.add(data); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |