Kaynağa Gözat

fix : 权限修改限制

bilingfeng 1 yıl önce
ebeveyn
işleme
745260df5f

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <解决bug调试修改> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <解决bug调试修改1> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 17 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthRoleServiceImpl.java

@@ -16,11 +16,15 @@ import com.zanxiang.game.module.manage.pojo.params.GameAuthRoleListParam;
 import com.zanxiang.game.module.manage.pojo.params.GameAuthRoleUpdateParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameAuthRoleVO;
 import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
+import com.zanxiang.game.module.manage.service.IGameAuthService;
+import com.zanxiang.game.module.mybatis.entity.GameAuth;
 import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
 import com.zanxiang.game.module.mybatis.mapper.GameAuthRoleMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -40,6 +44,9 @@ public class GameAuthRoleServiceImpl extends ServiceImpl<GameAuthRoleMapper, Gam
     @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
     private ISysUserRpc sysUserRpc;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     public Map<Long, String> getUserByAuthType(String authType) {
         List<GameAuthRole> authRoleList = super.list(new LambdaQueryWrapper<GameAuthRole>()
@@ -96,6 +103,16 @@ public class GameAuthRoleServiceImpl extends ServiceImpl<GameAuthRoleMapper, Gam
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean deleteById(Long id) {
+        //查询用户是否存在游戏
+        GameAuthRole gameAuthRole = super.getById(id);
+        if (gameAuthRole == null) {
+            return false;
+        }
+        if (gameAuthService.count(new LambdaQueryWrapper<GameAuth>()
+                .eq(GameAuth::getUserId, gameAuthRole.getUserId())
+        ) > 0) {
+            throw new BaseException("该角色存在分配的游戏, 禁止删除");
+        }
         return super.removeById(id);
     }
 

+ 3 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthServiceImpl.java

@@ -142,7 +142,9 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
         gameAuthVO.setUserName(userMap.get(gameAuthVO.getUserId()));
         GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
                 .eq(GameAuthRole::getUserId, gameAuthVO.getUserId()));
-        gameAuthVO.setAuthType(GameAuthEnum.getByValue(gameAuthRole.getAuthType()));
+        if (gameAuthRole != null) {
+            gameAuthVO.setAuthType(GameAuthEnum.getByValue(gameAuthRole.getAuthType()));
+        }
         return gameAuthVO;
     }