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())); + } + + }