feat: 角色删除功能
This commit is contained in:
parent
223bbc904c
commit
701fd52d45
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,8 @@ public interface AuthService {
|
||||
ResponseResult updateRole(SystemRole systemRole);
|
||||
|
||||
ResponseResult addRole(SystemRole role);
|
||||
|
||||
ResponseResult delRole(SystemRole systemRole);
|
||||
|
||||
ResponseResult delRoleRealy(SystemRole systemRole);
|
||||
}
|
||||
|
@ -94,14 +94,9 @@ 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("权限不足");
|
||||
}
|
||||
}else{
|
||||
int result = roleMapper.updateById(systemRole);
|
||||
if(result == 1) {
|
||||
return ResponseResult.success(systemRole);
|
||||
@ -110,6 +105,8 @@ public class AuthServiceImpl implements AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult addRole(SystemRole role) {
|
||||
// todo 此处可以进行性能优化,获取level从redis中获取
|
||||
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user