优化
This commit is contained in:
parent
df6a55bf70
commit
c7072bed10
@ -1,6 +1,7 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -46,4 +47,9 @@ public class SystemRoleMenu implements Serializable {
|
||||
@Excel(name = "菜单类型,0:模块 1:菜单;2:按钮", width = 15)
|
||||
@ApiModelProperty(value = "菜单类型,0:模块 1:菜单;2:按钮")
|
||||
private Integer type;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "子集数量")
|
||||
private Integer children = 0;
|
||||
|
||||
}
|
||||
|
||||
@ -135,8 +135,31 @@ public class BaseMenuServiceImpl extends ServiceImpl<BaseMenuMapper, BaseMenu> i
|
||||
@Override
|
||||
public List<SystemRoleMenu> roleMenu(String roleId) {
|
||||
// 查询角色下的菜单
|
||||
return systemRoleMenuService.list(Wrappers.<SystemRoleMenu>lambdaQuery()
|
||||
List<SystemRoleMenu> systemRoleMenus = systemRoleMenuService.list(Wrappers.<SystemRoleMenu>lambdaQuery()
|
||||
.eq(SystemRoleMenu::getRoleId, roleId));
|
||||
List<Long> menuIds = systemRoleMenus.stream().filter(s -> s.getType() == 1).map(s -> s.getAuthorityId()).collect(Collectors.toList());
|
||||
if (menuIds.size() == 0) {
|
||||
menuIds.add(0L);
|
||||
}
|
||||
List<BaseMenu> baseMenuList = baseMenuMapper.selectList(Wrappers.<BaseMenu>lambdaQuery().in(BaseMenu::getMenuId, menuIds));
|
||||
List<Long> actionIds = systemRoleMenus.stream().filter(s -> s.getType() == 2).map(s -> s.getAuthorityId()).collect(Collectors.toList());
|
||||
if (actionIds.size() == 0) {
|
||||
actionIds.add(0L);
|
||||
}
|
||||
List<BaseAction> baseActionList = baseActionMapper.selectList(Wrappers.<BaseAction>lambdaQuery().in(BaseAction::getActionId, actionIds));
|
||||
systemRoleMenus.stream().forEach(s -> {
|
||||
if (s.getType() == 0) {
|
||||
s.setChildren(baseMenuList.stream().filter(b -> b.getModuleId().equals(s.getAuthorityId())).collect(Collectors.toList()).size());
|
||||
} else if (s.getType() == 1) {
|
||||
int number = baseMenuList.stream().filter(b -> b.getParentId().equals(s.getAuthorityId())).collect(Collectors.toList()).size();
|
||||
if (number == 0) {
|
||||
number = baseActionList.stream().filter(a -> a.getMenuId().equals(s.getAuthorityId())).collect(Collectors.toList()).size();
|
||||
}
|
||||
s.setChildren(number);
|
||||
}
|
||||
});
|
||||
return systemRoleMenus;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user