mirror of https://gitee.com/stylefeng/roses
【7.2.5】【role】更新删除管理员
parent
f25872d6a5
commit
b4e663ff8f
|
@ -144,4 +144,13 @@ public interface RoleServiceApi {
|
|||
*/
|
||||
List<MenuAndButtonTreeResponse> grantButtonGrantAll(SysRoleRequest sysRoleRequest);
|
||||
|
||||
/**
|
||||
* 删除系统角色
|
||||
*
|
||||
* @param sysRoleRequest 删除参数
|
||||
* @author majianguo
|
||||
* @date 2020/11/5 上午11:14
|
||||
*/
|
||||
void del(SysRoleRequest sysRoleRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -52,15 +52,6 @@ public interface SysRoleService extends IService<SysRole>, RoleServiceApi {
|
|||
*/
|
||||
void add(SysRoleRequest sysRoleRequest);
|
||||
|
||||
/**
|
||||
* 删除系统角色
|
||||
*
|
||||
* @param sysRoleRequest 删除参数
|
||||
* @author majianguo
|
||||
* @date 2020/11/5 上午11:14
|
||||
*/
|
||||
void del(SysRoleRequest sysRoleRequest);
|
||||
|
||||
/**
|
||||
* 编辑系统角色
|
||||
*
|
||||
|
|
|
@ -135,9 +135,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
public void del(SysRoleRequest sysRoleRequest) {
|
||||
SysRole sysRole = this.querySysRole(sysRoleRequest);
|
||||
|
||||
// 超级管理员不能删除
|
||||
if (YesOrNotEnum.Y.getCode().equals(sysRole.getRoleSystemFlag())) {
|
||||
throw new ServiceException(SysRoleExceptionEnum.SYSTEM_ROLE_CANT_DELETE);
|
||||
// 超级管理员不能删除,但是管理角色可以删除
|
||||
if (!YesOrNotEnum.Y.getCode().equals(sysRole.getAdminFlag())) {
|
||||
if (YesOrNotEnum.Y.getCode().equals(sysRole.getRoleSystemFlag())) {
|
||||
throw new ServiceException(SysRoleExceptionEnum.SYSTEM_ROLE_CANT_DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
// 逻辑删除,设为删除标志
|
||||
|
|
|
@ -87,8 +87,8 @@ public class SysUserAdminController {
|
|||
* @date 2022/9/28 20:28
|
||||
*/
|
||||
@PostResource(name = "删除后台管理员", path = "/sysUser/backAuth/delAdmin")
|
||||
public ResponseData<?> delAdmin(@RequestBody SysAdminRequest sysAdminRequest) {
|
||||
|
||||
public ResponseData<?> delAdmin(@RequestBody @Validated(BaseRequest.delete.class) SysAdminRequest sysAdminRequest) {
|
||||
this.sysUserAdminService.deleteAdminUser(sysAdminRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import cn.stylefeng.roses.kernel.system.api.pojo.user.request.SysAdminRequest;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理员用户业务
|
||||
* 后台管理员用户业务
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/30 11:05
|
||||
|
@ -54,4 +54,12 @@ public interface SysUserAdminService {
|
|||
*/
|
||||
void addAdminUser(SysAdminRequest sysAdminRequest);
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/30 13:52
|
||||
*/
|
||||
void deleteAdminUser(SysAdminRequest sysAdminRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -117,6 +117,21 @@ public class SysUserAdminServiceImpl implements SysUserAdminService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAdminUser(SysAdminRequest sysAdminRequest) {
|
||||
|
||||
// 获取用户绑定的角色
|
||||
List<Long> roleIdList = this.sysUserRoleService.findRoleIdsByUserId(sysAdminRequest.getUserId());
|
||||
|
||||
// 删除角色
|
||||
for (Long roleId : roleIdList) {
|
||||
SysRoleRequest sysRoleRequest = new SysRoleRequest();
|
||||
sysRoleRequest.setRoleId(roleId);
|
||||
this.roleServiceApi.del(sysRoleRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个添加管理员用户
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue