| | |
| | | package com.ruoyi.study.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | @Override |
| | | public void checkDifficulty(Integer difficulty, Integer week, TGame game) { |
| | | // 判断用户是否完成上一个等级 |
| | | Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty)); |
| | | if (null == level) { |
| | | throw new GlobalException("游戏等级异常,请重试!"); |
| | | } |
| | | // 获取用户游戏进度 |
| | | Integer userId = tokenService.getLoginUserStudy().getUserid(); |
| | | 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("请先完成上一难度再挑战当前难度!"); |
| | | if (!Constants.ZERO.equals(difficulty)) { |
| | | Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty)); |
| | | if (null == level) { |
| | | throw new GlobalException("游戏等级异常,请重试!"); |
| | | } |
| | | // 获取用户游戏进度 |
| | | Integer userId = tokenService.getLoginUserStudy().getUserid(); |
| | | 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("请先完成上一难度再挑战当前难度!"); |
| | | } |
| | | } |
| | | } |
| | | |