权限修改

This commit is contained in:
张松 2025-05-26 14:11:38 +08:00
parent 4f86e6b44b
commit fe4fcd82f1
3 changed files with 32 additions and 7 deletions

View File

@ -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
) {

View File

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

View File

@ -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("保存失败");
}
}