| | |
| | | |
| | | 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; |
| | |
| | | // 随机获取一组题 |
| | | 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); |
| | | // 获取问题题目 和 回答题目 |
| | | List<String> ids = new ArrayList<>(); |
| | | ids.add(String.valueOf(data.getSubject())); |
| | | ids.add(String.valueOf(data.getAnswerSubject())); |
| | | ids.add(String.valueOf(one.getSubject())); |
| | | ids.add(String.valueOf(one.getAnswerSubject())); |
| | | // 有问有答 |
| | | List<TSubject> subjects = getSubjects(ids.toArray(ids.toArray(new String[0]))); |
| | | return new StudyAnswerResultVO(data, subjects); |
| | | 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 |