From f0cb2ed0aed012ae08fd957338650d91c3cc1d14 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 17 六月 2024 11:43:16 +0800
Subject: [PATCH] 修改
---
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
index e1cb646..3fe0e68 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -1,6 +1,7 @@
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;
@@ -58,16 +59,18 @@
@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("请先完成上一难度再挑战当前难度!");
+ }
}
}
--
Gitblit v1.7.1