权限修改
This commit is contained in:
parent
4f86e6b44b
commit
fe4fcd82f1
|
|
@ -11,9 +11,14 @@ public record RoleAddDTO(
|
|||
String name,
|
||||
// 角色级别
|
||||
Integer level,
|
||||
// 菜单id
|
||||
@NotEmpty(message = "菜单id不能为空")
|
||||
List<Long> menuIdList,
|
||||
/**
|
||||
* 管理员菜单id
|
||||
*/
|
||||
List<Long> adminMenuIdList,
|
||||
/**
|
||||
* 收银机菜单id
|
||||
*/
|
||||
List<Long> cashMenuIdList,
|
||||
// 描述
|
||||
String description
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,14 @@ public class RoleEditDTO {
|
|||
// 角色等级
|
||||
private Integer level;
|
||||
// 菜单id
|
||||
@NotNull
|
||||
private List<Long> menuIdList;
|
||||
/**
|
||||
* 管理员菜单id
|
||||
*/
|
||||
List<Long> adminMenuIdList;
|
||||
/**
|
||||
* 收银机菜单id
|
||||
*/
|
||||
List<Long> cashMenuIdList;
|
||||
// 描述
|
||||
private String description;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
|
|||
sysRole.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
boolean save = save(sysRole);
|
||||
if (save) {
|
||||
return addMenu(sysRole.getId(), roleAddDTO.menuIdList(), true);
|
||||
if (roleAddDTO.adminMenuIdList() != null && !roleAddDTO.adminMenuIdList().isEmpty()) {
|
||||
addMenu(sysRole.getId(), roleAddDTO.adminMenuIdList(), true);
|
||||
}
|
||||
|
||||
if (roleAddDTO.cashMenuIdList() != null && !roleAddDTO.cashMenuIdList().isEmpty()) {
|
||||
addMenu(sysRole.getId(), roleAddDTO.cashMenuIdList(), false);
|
||||
}
|
||||
}
|
||||
|
||||
throw new ApiNotPrintException("保存失败");
|
||||
|
|
@ -264,8 +270,16 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
|
|||
boolean b = updateById(role);
|
||||
if (b) {
|
||||
sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, role.getId()).remove();
|
||||
return addMenu(role.getId(), roleEditDTO.getMenuIdList(), true);
|
||||
|
||||
if (roleEditDTO.getAdminMenuIdList() != null && !roleEditDTO.getAdminMenuIdList().isEmpty()) {
|
||||
addMenu(role.getId(), roleEditDTO.getAdminMenuIdList(), true);
|
||||
}
|
||||
|
||||
if (roleEditDTO.getCashMenuIdList() != null && !roleEditDTO.getCashMenuIdList().isEmpty()) {
|
||||
addMenu(role.getId(), roleEditDTO.getCashMenuIdList(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
throw new ApiNotPrintException("保存失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue