| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.RedisConstants; |
| | |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.goods.api.feignClient.GoodsClient; |
| | | import com.ruoyi.goods.api.model.TGoodsVO; |
| | | import com.ruoyi.management.api.feignClient.ManagementClient; |
| | | import com.ruoyi.study.domain.*; |
| | | import com.ruoyi.study.dto.*; |
| | | import com.ruoyi.study.service.*; |
| | |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<TUserStudy> studySchedule(@RequestParam Integer week, @RequestParam Integer day) { |
| | | TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week, day); |
| | | TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week); |
| | | return R.ok(result); |
| | | } |
| | | /** |
| | |
| | | * @param day 所属day |
| | | */ |
| | | @GetMapping("/listenSelectPicture") |
| | | @ApiOperation(value = "自主学习1-听音选图", tags = {"学习端-首页"}) |
| | | @ApiOperation(value = "自主学习1-听音选图", tags = {"学习端-听-自主学习"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<StudyListenResultVO> listenSelectPicture(@RequestParam Integer week, @RequestParam Integer day) { |
| | | public R<StudyListenResultVO> listenSelectPicture(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { |
| | | // 判断当前登录用户是否为 会员 |
| | | Boolean isVip = userService.isVip(); |
| | | LambdaQueryChainWrapper<TStudyListen> wrapper = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week) |
| | | .eq(TStudyListen::getDay, day).eq(TStudyListen::getDisabled, 0); |
| | | |
| | | // 非会员只能查看非会员题目,会员可以查看所有题目 |
| | | // if (!isVip) { |
| | | // wrapper.eq(TStudyListen::getIsVip, 0); |
| | | // } |
| | | List<TStudyListen> studyListens = wrapper.list(); |
| | | List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day); |
| | | for (TStudyListen studyListen : studyListens) { |
| | | if (studyListen.getIsVip() == 1){ |
| | | if (studyListen.getIsVip() == 1) { |
| | | // 需要会员查看 |
| | | if (!isVip){ |
| | | if (!isVip) { |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | } |
| | |
| | | * @param day 所属day |
| | | */ |
| | | @GetMapping("/pictureSelectVoice") |
| | | @ApiOperation(value = "自主学习2-看图选音", tags = {"学习端-首页"}) |
| | | @ApiOperation(value = "自主学习2-看图选音", tags = {"学习端-听-自主学习"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<StudyLookResultVO> pictureSelectVoice(@RequestParam Integer week, @RequestParam Integer day) { |
| | | public R<StudyLookResultVO> pictureSelectVoice(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { |
| | | // 判断当前登录用户是否为 会员 |
| | | Boolean isVip = userService.isVip(); |
| | | LambdaQueryChainWrapper<TStudyLook> wrapper = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) |
| | | .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0); |
| | | // 非会员只能查看非会员题目,会员可以查看所有题目 |
| | | |
| | | List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) |
| | | .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0).list(); |
| | | List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day); |
| | | for (TStudyLook studyListen : lookList) { |
| | | if (studyListen.getIsVip() == 1){ |
| | | if (studyListen.getIsVip() == 1) { |
| | | // 需要会员查看 |
| | | if (!isVip){ |
| | | if (!isVip) { |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | } |
| | |
| | | * @param day 所属day |
| | | */ |
| | | @GetMapping("/induceExclude") |
| | | @ApiOperation(value = "自主学习3-归纳排除", tags = {"学习端-首页"}) |
| | | @ApiOperation(value = "自主学习3-归纳排除", tags = {"学习端-听-自主学习"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<StudyInductionResultVO> induceExclude(@RequestParam Integer week, @RequestParam Integer day) { |
| | | public R<StudyInductionResultVO> induceExclude(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { |
| | | // 判断当前登录用户是否为 会员 |
| | | Boolean isVip = userService.isVip(); |
| | | LambdaQueryChainWrapper<TStudyInduction> wrapper = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week) |
| | | .eq(TStudyInduction::getDay, day).eq(TStudyInduction::getDisabled, 0); |
| | | // 非会员只能查看非会员题目,会员可以查看所有题目 |
| | | // if (!isVip) { |
| | | // wrapper.eq(TStudyInduction::getIsVip, 0); |
| | | // } |
| | | List<TStudyInduction> inductionList = wrapper.list(); |
| | | List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); |
| | | for (TStudyInduction studyListen : inductionList) { |
| | | if (studyListen.getIsVip() == 1){ |
| | | if (studyListen.getIsVip() == 1) { |
| | | // 需要会员查看 |
| | | if (!isVip){ |
| | | if (!isVip) { |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | } |
| | |
| | | * @param day 所属day |
| | | */ |
| | | @GetMapping("/questionsAndAnswers") |
| | | @ApiOperation(value = "自主学习4-有问有答", tags = {"学习端-首页"}) |
| | | @ApiOperation(value = "自主学习4-有问有答", tags = {"学习端-听-自主学习"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<StudyAnswerResultVO> questionsAndAnswers(@RequestParam Integer week, @RequestParam Integer day) { |
| | | public R<StudyAnswerResultVO> questionsAndAnswers(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { |
| | | // 判断当前登录用户是否为 会员 |
| | | Boolean isVip = userService.isVip(); |
| | | LambdaQueryChainWrapper<TStudyAnswer> wrapper = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getWeek, week) |
| | | .eq(TStudyAnswer::getDay, day).eq(TStudyAnswer::getDisabled, 0); |
| | | // 非会员只能查看非会员题目,会员可以查看所有题目 |
| | | // if (!isVip) { |
| | | // wrapper.eq(TStudyAnswer::getIsVip, 0); |
| | | // } |
| | | List<TStudyAnswer> answerList = wrapper.list(); |
| | | List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); |
| | | for (TStudyAnswer studyListen : answerList) { |
| | | if (studyListen.getIsVip() == 1){ |
| | | if (studyListen.getIsVip() == 1) { |
| | | // 需要会员查看 |
| | | if (!isVip){ |
| | | if (!isVip) { |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | } |
| | |
| | | * @param day 所属day |
| | | */ |
| | | @GetMapping("/pictureMateVoice") |
| | | @ApiOperation(value = "自主学习5-音图相配", tags = {"学习端-首页"}) |
| | | @ApiOperation(value = "自主学习5-音图相配", tags = {"学习端-听-自主学习"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) |
| | | }) |
| | | public R<StudyPairResultVO> pictureMateVoice(@RequestParam Integer week, @RequestParam Integer day) { |
| | | public R<StudyPairResultVO> pictureMateVoice(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { |
| | | // 判断当前登录用户是否为 会员 |
| | | Boolean isVip = userService.isVip(); |
| | | LambdaQueryChainWrapper<TStudyPair> wrapper = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) |
| | | .eq(TStudyPair::getDay, day).eq(TStudyPair::getDisabled, 0); |
| | | // 非会员只能查看非会员题目,会员可以查看所有题目 |
| | | if (!isVip) { |
| | | wrapper.eq(TStudyPair::getIsVip, 0); |
| | | } |
| | | TStudyPair pair = wrapper.one(); |
| | | if (pair.getIsVip() == 1){ |
| | | // 需要会员查看 |
| | | if (!isVip){ |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); |
| | | for (TStudyPair pair : pairList) { |
| | | if (pair.getIsVip() == 1) { |
| | | // 需要会员查看 |
| | | if (!isVip) { |
| | | // 不是会员 |
| | | return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(studyService.pictureMateVoice(week, day, pair)); |
| | | return R.ok(studyService.pictureMateVoice(week, day, pairList)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param completeStudy 完成学习信息 |
| | | */ |
| | | @PostMapping("/completeLearning") |
| | | @ApiOperation(value = "完成学习", tags = {"学习端-题目"}) |
| | | @ApiOperation(value = "完成学习", tags = {"学习端-听-自主学习"}) |
| | | public R<Boolean> completeLearning(@RequestBody CompleteStudyDTO completeStudy) { |
| | | // 登录用户id |
| | | Integer userId = tokenService.getLoginUserStudy().getUserid(); |
| | | // 获取user详细信息,改变积分 |
| | | // 判断是否已完成该题组 |
| | | boolean update = true; |
| | | if (completeStudy.getIsComplete()) { |
| | | List<Integer> studyIds = completeStudy.getStudyIds(); |
| | | Integer type = completeStudy.getType(); |
| | | int sum; |
| | | if (Constants.ONE.equals(type)) { |
| | | List<TStudyListen> studyListens = studyListenService.lambdaQuery().in(TStudyListen::getId, studyIds) |
| | | .eq(TStudyListen::getDisabled, 0).list(); |
| | | sum = studyListens.stream().mapToInt(TStudyListen::getIntegral).sum(); |
| | | } else if (Constants.TWO.equals(type)) { |
| | | List<TStudyLook> studyListens = studyLookService.lambdaQuery().in(TStudyLook::getId, studyIds) |
| | | .eq(TStudyLook::getDisabled, 0).list(); |
| | | sum = studyListens.stream().mapToInt(TStudyLook::getIntegral).sum(); |
| | | } else if (Constants.THREE.equals(type)) { |
| | | List<TStudyInduction> studyListens = studyInductionService.lambdaQuery().in(TStudyInduction::getId, studyIds) |
| | | .eq(TStudyInduction::getDisabled, 0).list(); |
| | | sum = studyListens.stream().mapToInt(TStudyInduction::getIntegral).sum(); |
| | | } else if (Constants.FOUR.equals(type)) { |
| | | List<TStudyAnswer> studyListens = studyAnswerService.lambdaQuery().in(TStudyAnswer::getId, studyIds) |
| | | .eq(TStudyAnswer::getDisabled, 0).list(); |
| | | sum = studyListens.stream().mapToInt(TStudyAnswer::getIntegral).sum(); |
| | | } else if (Constants.FIVE.equals(type)) { |
| | | List<TStudyPair> studyListens = studyPairService.lambdaQuery().in(TStudyPair::getId, studyIds) |
| | | .eq(TStudyPair::getDisabled, 0).list(); |
| | | sum = studyListens.stream().mapToInt(TStudyPair::getIntegral).sum(); |
| | | } else { |
| | | return R.fail("题目信息异常!"); |
| | | } |
| | | // 获取user详细信息,改变积分 |
| | | TUser user = userService.getById(userId); |
| | | user.setIntegral(user.getIntegral() + completeStudy.getIntegral()); |
| | | user.setIntegral(user.getIntegral() + sum); |
| | | update = userService.updateById(user); |
| | | // 生成积分明细记录 |
| | | TIntegralRecord integralRecord = new TIntegralRecord(); |
| | | integralRecord.setIntegral(String.valueOf(sum)); |
| | | integralRecord.setMethod(Constants.COMPLETE_LEARNING); |
| | | integralRecord.setUserId(userId); |
| | | update = update && integralRecordService.save(integralRecord); |
| | | } |
| | | // 生成积分明细记录 |
| | | TIntegralRecord integralRecord = new TIntegralRecord(); |
| | | integralRecord.setIntegral(String.valueOf(completeStudy.getIntegral())); |
| | | integralRecord.setMethod(completeStudy.getMethod()); |
| | | integralRecord.setUserId(userId); |
| | | return R.ok(update && integralRecordService.save(integralRecord)); |
| | | // 学习配置列表 |
| | | List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0).orderByAsc(TStudy::getWeek).list(); |
| | | if (studyList.isEmpty()) { |
| | | throw new GlobalException("学习配置列表未配置或数据失效!"); |
| | | } |
| | | // 更改学习记录 |
| | | Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(studyList, userId, completeStudy); |
| | | return R.ok(update && updateStudyRecord); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param week 所属周目 |
| | | */ |
| | | @GetMapping("/gameHearing") |
| | | @ApiOperation(value = "自主游戏1-超级听力", tags = {"学习端-游戏"}) |
| | | @ApiOperation(value = "自主游戏1-超级听力", tags = {"学习端-听-自主游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) |
| | |
| | | * @param week 所属周目 |
| | | */ |
| | | @GetMapping("/gameMemory") |
| | | @ApiOperation(value = "自主游戏2-超级记忆", tags = {"学习端-游戏"}) |
| | | @ApiOperation(value = "自主游戏2-超级记忆", tags = {"学习端-听-自主游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) |
| | |
| | | * @param completeStudy 学习信息 |
| | | */ |
| | | @PostMapping("/gameAchievement") |
| | | @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"学习端-游戏"}) |
| | | @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"学习端-听-自主游戏"}) |
| | | public R<Boolean> gameAchievement(@RequestBody CompleteGameDTO completeStudy) { |
| | | /* |
| | | * 游戏测试需要根据正确率计算本次测试可获得积分 |
| | |
| | | Boolean add = gameRecordService.add(completeStudy); |
| | | // 可获得积分不为null时,才添加积分明细记录 |
| | | if (null != availableIntegral) { |
| | | add = add && integralRecordService.add(String.valueOf(availableIntegral), completeStudy.getMethod(), completeStudy.getGameId(), null); |
| | | add = add && integralRecordService.add(String.valueOf(availableIntegral), Constants.COMPLETE_GAME, completeStudy.getGameId(), null); |
| | | // 用户账户添加积分 |
| | | TUser user = userService.getById(userid); |
| | | user.setIntegral(user.getIntegral() + availableIntegral); |
| | |
| | | * @param week 周目 |
| | | */ |
| | | @GetMapping("/lookPictureDbu") |
| | | @ApiOperation(value = "自主故事1-看图配音", tags = {"学习端-故事"}) |
| | | @ApiOperation(value = "自主故事1-看图配音", tags = {"学习端-听-自主故事"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) |
| | | }) |
| | |
| | | * @param week 周目 |
| | | */ |
| | | @GetMapping("/frameworkMemory") |
| | | @ApiOperation(value = "自主故事2-框架记忆", tags = {"学习端-故事"}) |
| | | @ApiOperation(value = "自主故事2-框架记忆", tags = {"学习端-听-自主故事"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) |
| | | }) |
| | |
| | | } else { |
| | | subjectList = new ArrayList<>(); |
| | | } |
| | | return R.ok(new StudyStoryListenResultVO(listen,subjectList)); |
| | | return R.ok(new StudyStoryListenResultVO(listen, subjectList)); |
| | | } |
| | | |
| | | /** |
| | | * 完成故事类型 |
| | | */ |
| | | @GetMapping("/completeStory") |
| | | @ApiOperation(value = "完成故事学习", tags = {"学习端-故事"}) |
| | | @ApiOperation(value = "完成故事学习", tags = {"学习端-听-自主故事"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "积分数量", name = "integral", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "完成答题/完成听故事", name = "method", dataType = "String", required = true) |
| | | @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Boolean> completeStory(@RequestParam Integer integral, @RequestParam Integer storyId, |
| | | @RequestParam String method) { |
| | | public R<Boolean> completeStory(@RequestParam Integer integral, @RequestParam Integer storyId) { |
| | | TStoryListen storyListen = storyListenService.lambdaQuery().eq(TStoryListen::getId, storyId).eq(TStoryListen::getDisabled, 0).one(); |
| | | if (null == storyListen) { |
| | | throw new GlobalException("当前故事学习失败,故事信息异常,请重试!"); |
| | |
| | | Boolean result = true; |
| | | if (null == integralRecord) { |
| | | // 添加积分明细记录 |
| | | result = integralRecordService.add(String.valueOf(integral), method, null, storyId); |
| | | result = integralRecordService.add(String.valueOf(integral), Constants.COMPLETE_STORY, null, storyId); |
| | | TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one(); |
| | | // 添加积分 |
| | | user.setIntegral(user.getIntegral() + integral); |
| | |
| | | .eq(TGameRecord::getDisabled, 0).list(); |
| | | return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); |
| | | } |
| | | |
| | | @GetMapping("/record") |
| | | @ApiOperation(value = "游戏测试成绩", tags = {"家长端-游戏测试成绩"}) |
| | | public R<StudyRecordResultVO> record() { |
| | | LoginUserParent loginUser1 = tokenService.getLoginUser1(); |
| | | if (loginUser1 == null){ |
| | | if (loginUser1 == null) { |
| | | return R.tokenError("登陆失效,请重新登录"); |
| | | } |
| | | Integer userId = loginUser1.getUserid(); |
| | |
| | | .eq(TGameRecord::getDisabled, 0).list(); |
| | | return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); |
| | | } |
| | | |
| | | @GetMapping("/getIntegral") |
| | | @ApiOperation(value = "获取剩余积分", tags = {"家长端-获取剩余积分"}) |
| | | public R<Integer> getIntegral() { |
| | | Integer userId = tokenService.getLoginUser1().getUserid(); |
| | | return R.ok(userService.getById(userId).getIntegral()); |
| | | } |
| | | |
| | | @GetMapping("/getIntegralStudy") |
| | | @ApiOperation(value = "获取剩余积分", tags = {"学习端-获取剩余积分"}) |
| | | public R<Integer> getIntegralStudy() { |
| | |
| | | public R<IPage<TIntegralRecord>> integralDetail(String time, |
| | | @RequestParam("pageNum") Integer pageNum, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | if(tokenService.getLoginUserStudy() == null){ |
| | | if (tokenService.getLoginUserStudy() == null) { |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUserStudy().getUserid(), time)); |
| | | } |
| | | |
| | | @GetMapping("/integralDetailParent") |
| | | @ApiOperation(value = "个人中心-积分明细", tags = {"家长端"}) |
| | | @ApiImplicitParams({ |