【7.2.5】【role】更新删除管理员

pull/37/head
fengshuonan 2022-09-30 14:04:06 +08:00
parent f25872d6a5
commit b4e663ff8f
6 changed files with 40 additions and 15 deletions

View File

@ -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);
}

View File

@ -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);
/**
*
*

View File

@ -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);
}
}
// 逻辑删除,设为删除标志

View File

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

View File

@ -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);
}

View File

@ -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);
}
}
/**
*
*