From 701fd52d455d14b7eb672ca5529fb04609ecde72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Wed, 6 Nov 2024 17:36:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=92=E8=89=B2=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/AuthController.java | 9 ++++++ .../harmony/service/AuthService.java | 4 +++ .../harmony/service/impl/AuthServiceImpl.java | 30 ++++++++++++------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/AuthController.java b/src/main/java/com/guaiguailang/harmony/controller/AuthController.java index e7a3d74..43b4687 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/AuthController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/AuthController.java @@ -3,6 +3,7 @@ package com.guaiguailang.harmony.controller; import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.util.SaResult; import com.guaiguailang.harmony.domain.dto.ParamLogin; +import com.guaiguailang.harmony.domain.entity.MenuDataItem; import com.guaiguailang.harmony.domain.entity.SystemRole; import com.guaiguailang.harmony.domain.vo.ResponseResult; import com.guaiguailang.harmony.service.AuthService; @@ -115,4 +116,12 @@ public class AuthController { public ResponseEntity addRole(@RequestBody SystemRole role) { return ResponseEntity.ok(authService.addRole(role)); } + @DeleteMapping("/role-del") + public ResponseEntity delRole(@RequestBody SystemRole systemRole) { + return ResponseEntity.ok(authService.delRole(systemRole)); + } + @DeleteMapping("/role-del-realy") + public ResponseEntity delRoleRealy(@RequestBody SystemRole systemRole) { + return ResponseEntity.ok(authService.delRoleRealy(systemRole)); + } } diff --git a/src/main/java/com/guaiguailang/harmony/service/AuthService.java b/src/main/java/com/guaiguailang/harmony/service/AuthService.java index 4d9933d..7d5fd38 100644 --- a/src/main/java/com/guaiguailang/harmony/service/AuthService.java +++ b/src/main/java/com/guaiguailang/harmony/service/AuthService.java @@ -15,4 +15,8 @@ public interface AuthService { ResponseResult updateRole(SystemRole systemRole); ResponseResult addRole(SystemRole role); + + ResponseResult delRole(SystemRole systemRole); + + ResponseResult delRoleRealy(SystemRole systemRole); } diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/AuthServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/AuthServiceImpl.java index 6acbe15..cda15f5 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/AuthServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/AuthServiceImpl.java @@ -94,20 +94,17 @@ public class AuthServiceImpl implements AuthService { Long id = Long.parseLong(StpUtil.getLoginId().toString());// 获取用户id // 获取level SystemRole systemRoleCreator = userMapper.getRoleLevelByUserId(id); -// if(userInfo.getLevel()!=1){ -// // 仅限超级管理员(1)能操作所有 -// } - // 算了,先不给超级管理员特权 - if(systemRole.getLevel()<=systemRoleCreator.getLevel()){ return ResponseResult.error("权限不足"); - } - int result = roleMapper.updateById(systemRole); - if(result == 1) { - return ResponseResult.success(systemRole); }else{ - return ResponseResult.error("更新失败"); + int result = roleMapper.updateById(systemRole); + if(result == 1) { + return ResponseResult.success(systemRole); + }else{ + return ResponseResult.error("更新失败"); + } } + } @Override @@ -124,4 +121,17 @@ public class AuthServiceImpl implements AuthService { // 角色等级校验 return ResponseResult.success(roleMapper.insert(role)); } + + @Override + public ResponseResult delRole(SystemRole systemRole) { + systemRole.setStatus(0); + return ResponseResult.success(roleMapper.updateById(systemRole)); + } + + @Override + public ResponseResult delRoleRealy(SystemRole systemRole) { + return ResponseResult.success(roleMapper.deleteById(systemRole.getId())); + } + + }