|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.ruoyi.common.core.constant.Constants; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/subjectList") | 
|---|
|  |  |  | //    @ApiOperation(value = "配置学习类型选择题目", tags = {"题目管理"}) | 
|---|
|  |  |  | public R<PageInfo<TSubject>> subjectList(@RequestBody ChoiceSubject query) { | 
|---|
|  |  |  | PageInfo<TSubject> res = new PageInfo<>(query.getPageNumber(), query.getPageSize()); | 
|---|
|  |  |  | QueryWrapper<TSubject> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | public R<IPage<TSubject>> subjectList(@RequestBody ChoiceSubject query) { | 
|---|
|  |  |  | // 创建分页对象,传入当前页和每页显示条数 | 
|---|
|  |  |  | IPage<TSubject> page = new Page<>(query.getPageNumber(), query.getPageSize());        QueryWrapper<TSubject> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | if (StringUtils.hasLength(query.getName())) { | 
|---|
|  |  |  | wrapper.like("name", query.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TCategory> list5 = categoryService.list(); | 
|---|
|  |  |  | wrapper.eq("state", 1); | 
|---|
|  |  |  | List<TSubject> list = subjectService.list(wrapper); | 
|---|
|  |  |  | // 执行分页查询 | 
|---|
|  |  |  | IPage<TSubject> res = subjectService.page(page, wrapper); | 
|---|
|  |  |  | List<TSubject> list = res.getRecords(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | switch (query.getStudyType()) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list); | 
|---|
|  |  |  | res.setTotal(list.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | // 查询出error字段不为空的数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(tSubjects); | 
|---|
|  |  |  | res.setTotal(tSubjects.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | List<TSubject> list2 = subjectService.list(wrapper); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list2); | 
|---|
|  |  |  | res.setTotal(list2.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | // 查询出error字段不为空的数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(tSubjects3); | 
|---|
|  |  |  | res.setTotal(tSubjects3.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | List<TSubject> list4 = subjectService.list(wrapper); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list4); | 
|---|
|  |  |  | res.setTotal(list4.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSubject> objects = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyId.setAnswerCount(game.getAnswerCount()); | 
|---|
|  |  |  | studyId.setRate(game.getRate()); | 
|---|
|  |  |  | studyId.setAnswerRate(game.getAnswerRate()); | 
|---|
|  |  |  | studyId.setSubjectIds(game.getSubjectIds()); | 
|---|
|  |  |  | studyId.setSubjectIdsOne(game.getSubjectIdsOne()); | 
|---|
|  |  |  | gameService.updateById(studyId); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 判断当前周目配置的题目数量 | 
|---|
|  |  |  | 
|---|
|  |  |  | tGame.setAnswerTime(game.getAnswerTime()); | 
|---|
|  |  |  | tGame.setAnswerIntegral(game.getAnswerIntegral()); | 
|---|
|  |  |  | tGame.setAnswerCount(game.getAnswerCount()); | 
|---|
|  |  |  | tGame.setSubjectIds(game.getSubjectIds()); | 
|---|
|  |  |  | tGame.setSubjectIdsOne(game.getSubjectIdsOne()); | 
|---|
|  |  |  | gameService.save(tGame); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyListen.setWeek(week); | 
|---|
|  |  |  | tStudyListen.setIsVip(studyListenDTO.getIsVip()); | 
|---|
|  |  |  | tStudyListen.setRate(dto.getListenRate()); | 
|---|
|  |  |  | tStudyListen.setStudySort(studyListenDTO.getStudySort()); | 
|---|
|  |  |  | studyListenService.save(tStudyListen); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids1 = studyLookService.lambdaQuery().eq(TStudyLook::getId, one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyLook.setWeek(week); | 
|---|
|  |  |  | tStudyLook.setIsVip(studyLookDTO.getIsVip()); | 
|---|
|  |  |  | tStudyLook.setRate(dto.getLookRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tStudyLook.setStudySort(studyLookDTO.getStudySort()); | 
|---|
|  |  |  | studyLookService.save(tStudyLook); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids2 = studyInductionService.lambdaQuery().eq(TStudyInduction::getId, one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyInduction.setIntegral(studyInductionDTO.getIntegral()); | 
|---|
|  |  |  | tStudyInduction.setWeek(week); | 
|---|
|  |  |  | tStudyInduction.setRate(dto.getInductionRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tStudyInduction.setIsVip(studyInductionDTO.getIsVip()); | 
|---|
|  |  |  | tStudyInduction.setStudySort(studyInductionDTO.getStudySort()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | studyInductionService.save(tStudyInduction); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids3 = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getId, one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyAnswer.setWeek(week); | 
|---|
|  |  |  | tStudyAnswer.setRate(dto.getAnswerRate()); | 
|---|
|  |  |  | tStudyAnswer.setIsVip(studyAnswerDTO.getIsVip()); | 
|---|
|  |  |  | tStudyAnswer.setStudySort(studyAnswerDTO.getStudySort()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | studyAnswerService.save(tStudyAnswer); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids4 = studyPairService.lambdaQuery().eq(TStudyPair::getId, one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyPair.setWeek(week); | 
|---|
|  |  |  | tStudyPair.setRate(dto.getPairRate()); | 
|---|
|  |  |  | tStudyPair.setIsVip(studyPairDTO.getIsVip()); | 
|---|
|  |  |  | tStudyPair.setStudySort(studyPairDTO.getStudySort()); | 
|---|
|  |  |  | studyPairService.save(tStudyPair); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 听音选图 | 
|---|
|  |  |  | List<TStudyListen> list = studyListenService.list(new QueryWrapper<TStudyListen>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day)); | 
|---|
|  |  |  | .eq("day", day).orderByAsc("studySort")); | 
|---|
|  |  |  | List<TSubject> list9 = subjectService.list(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (TStudyListen tStudyListen : list) { | 
|---|
|  |  |  | 
|---|
|  |  |  | studyListenVO.setIntegral(tStudyListen.getIntegral()); | 
|---|
|  |  |  | studyListenVO.setSubject(tStudyListen.getSubject()); | 
|---|
|  |  |  | studyListenVO.setIsVip(tStudyListen.getIsVip()); | 
|---|
|  |  |  | studyListenVO.setId(tStudyListen.getId()); | 
|---|
|  |  |  | studyListenVO.setType(tStudyListen.getType()); | 
|---|
|  |  |  | listenVOS.add(studyListenVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setListenRate(tStudyListen.getRate()); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 看音选图 | 
|---|
|  |  |  | List<TStudyLook> list1 = studyLookService.list(new QueryWrapper<TStudyLook>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day) | 
|---|
|  |  |  | .eq("day", day).orderByAsc("studySort") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (TStudyLook tStudyLook : list1) { | 
|---|
|  |  |  | int index = 0; | 
|---|
|  |  |  | 
|---|
|  |  |  | studyLookVO1.setIntegral(tStudyLook.getIntegral()); | 
|---|
|  |  |  | studyLookVO1.setSubject(tStudyLook.getSubject()); | 
|---|
|  |  |  | studyLookVO1.setIsVip(tStudyLook.getIsVip()); | 
|---|
|  |  |  | studyLookVO1.setId(tStudyLook.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | lookVOS.add(studyLookVO1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setLookRate(tStudyLook.getRate()); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 归纳排除 | 
|---|
|  |  |  | List<TStudyInduction> list2 = studyInductionService.list(new QueryWrapper<TStudyInduction>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day) | 
|---|
|  |  |  | .eq("day", day).orderByAsc("studySort") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (TStudyInduction tStudyInduction : list2) { | 
|---|
|  |  |  | StringBuilder names = new StringBuilder(); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyInductionVO.setIntegral(tStudyInduction.getIntegral()); | 
|---|
|  |  |  | studyInductionVO.setSubject(tStudyInduction.getSubject()); | 
|---|
|  |  |  | studyInductionVO.setIsVip(tStudyInduction.getIsVip()); | 
|---|
|  |  |  | studyInductionVO.setId(tStudyInduction.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | inductionVOS.add(studyInductionVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setInductionRate(tStudyInduction.getRate()); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 有问有答 | 
|---|
|  |  |  | List<TStudyAnswer> list3 = studyAnswerService.list(new QueryWrapper<TStudyAnswer>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day)); | 
|---|
|  |  |  | .eq("day", day).orderByAsc("studySort")); | 
|---|
|  |  |  | for (TStudyAnswer tStudyAnswer : list3) { | 
|---|
|  |  |  | StringBuilder names = new StringBuilder(); | 
|---|
|  |  |  | StudyAnswerVO studyAnswerVO = new StudyAnswerVO(); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyAnswerVO.setIsVip(tStudyAnswer.getIsVip()); | 
|---|
|  |  |  | studyAnswerVO.setIsAnswer(tStudyAnswer.getIsAnswer()); | 
|---|
|  |  |  | studyAnswerVO.setSubject(tStudyAnswer.getSubject() + "," + tStudyAnswer.getAnswerSubject()); | 
|---|
|  |  |  | studyAnswerVO.setId(tStudyAnswer.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | answerVOS.add(studyAnswerVO); | 
|---|
|  |  |  | res.setAnswerRate(tStudyAnswer.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | // 音图相配 | 
|---|
|  |  |  | List<TStudyPair> list4 = studyPairService.list(new QueryWrapper<TStudyPair>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day) | 
|---|
|  |  |  | .eq("day", day).orderByAsc("studySort") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (TStudyPair tStudyPair : list4) { | 
|---|
|  |  |  | StringBuilder names = new StringBuilder(); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyPairVO.setIntegral(tStudyPair.getIntegral()); | 
|---|
|  |  |  | studyPairVO.setSubject(tStudyPair.getSubject()); | 
|---|
|  |  |  | studyPairVO.setIsVip(tStudyPair.getIsVip()); | 
|---|
|  |  |  | studyPairVO.setId(tStudyPair.getId()); | 
|---|
|  |  |  | pairVOS.add(studyPairVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setPairRate(tStudyPair.getRate()); | 
|---|
|  |  |  | 
|---|
|  |  |  | gameVO.setAnswerCount(tGame.getAnswerCount()); | 
|---|
|  |  |  | gameVO.setRate(tGame.getRate()); | 
|---|
|  |  |  | gameVO.setAnswerRate(tGame.getAnswerRate()); | 
|---|
|  |  |  | String subjectIds = tGame.getSubjectIds(); | 
|---|
|  |  |  | if(subjectIds!=null && subjectIds.length()>0){ | 
|---|
|  |  |  | gameVO.setSubjects(subjectService.list(new QueryWrapper<TSubject>() | 
|---|
|  |  |  | .in("id", subjectIds.split(",")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String subjectIdsOne = tGame.getSubjectIdsOne(); | 
|---|
|  |  |  | if(subjectIdsOne!=null && subjectIdsOne.length()>0){ | 
|---|
|  |  |  | gameVO.setSubjectsOne(subjectService.list(new QueryWrapper<TSubject>() | 
|---|
|  |  |  | .in("id", subjectIdsOne.split(",")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | gameVOS.add(gameVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TStoryListen> list6 = storyListenService.list(new QueryWrapper<TStoryListen>() | 
|---|
|  |  |  | 
|---|
|  |  |  | game.setTime(game.getTime().split(",")[difficulty]); | 
|---|
|  |  |  | // 检验是否完成难度 | 
|---|
|  |  |  | studyService.checkDifficulty(difficulty, week, game, userStudy.getUserid()); | 
|---|
|  |  |  | List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | List<String> subjectId = new ArrayList<>(); | 
|---|
|  |  |  | String subjectIds = game.getSubjectIds(); | 
|---|
|  |  |  | if(subjectIds!=null){ | 
|---|
|  |  |  | String[] split = subjectIds.split(","); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | subjectId.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> newSubjectId = subjectId.stream().map(data -> { | 
|---|
|  |  |  | if (data.startsWith(Constants.REDUCE)) { | 
|---|
|  |  |  | data = data.replace(Constants.REDUCE, Constants.EMPTY_STR); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (null == game) { | 
|---|
|  |  |  | throw new GlobalException("当前季度该周目暂无配置游戏数据!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | //        List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | List<String> subjectId = new ArrayList<>(); | 
|---|
|  |  |  | String subjectIds = game.getSubjectIdsOne(); | 
|---|
|  |  |  | if(subjectIds!=null){ | 
|---|
|  |  |  | String[] split = subjectIds.split(","); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | subjectId.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> subjectData = getSubjectData(game, subjectId); | 
|---|
|  |  |  | List<TSubject> subjectList = getSubjectList(subjectData); | 
|---|
|  |  |  | // 返回数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(userService.updateById(user)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/lookVideo") | 
|---|
|  |  |  | //    @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"}) | 
|---|
|  |  |  | public R<Boolean> lookVideo() { | 
|---|
|  |  |  | boolean update = userService.update(new LambdaUpdateWrapper<TUser>().set(TUser::getLookVideo, 0)); | 
|---|
|  |  |  | return R.ok(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设置题组类型 常规 示例 | 
|---|
|  |  |  | * @param dto | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/setStudyType") | 
|---|
|  |  |  | public R<Object> setStudyType(@RequestBody SetStudyTypeDto dto){ | 
|---|
|  |  |  | TStudyListen studyListen = studyListenService.getById(dto.getId()); | 
|---|
|  |  |  | studyListen.setType(dto.getType()); | 
|---|
|  |  |  | studyListen.setSubject(dto.getSubject()); | 
|---|
|  |  |  | return R.ok(studyListenService.updateById(studyListen)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|