From 80b5033b8d5b918c7ca2523bc2a69139c2bab438 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期六, 15 六月 2024 19:21:33 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/DolphinEnglish

---
 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