use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacLoginServiceImpl method loginAfter.
@Override
public LoginRespDto loginAfter(Long applicationId) {
LoginRespDto loginRespDto = new LoginRespDto();
String loginName = SecurityUtils.getCurrentLoginName();
if (StringUtils.isEmpty(loginName)) {
log.error("操作超时, 请重新登录 loginName={}", loginName);
Preconditions.checkArgument(StringUtils.isNotEmpty(loginName), "操作超时, 请重新登录");
}
UacUser uacUser = uacUserService.findByLoginName(loginName);
if (PublicUtil.isEmpty(uacUser)) {
log.info("找不到用户信息 loginName={}", loginName);
throw new UacBizException(ErrorCodeEnum.UAC10011002, loginName);
}
LoginAuthDto loginAuthDto = this.getLoginAuthDto(uacUser);
List<MenuVo> menuVoList = uacMenuService.getMenuVoList(uacUser.getId(), applicationId);
if (PublicUtil.isNotEmpty(menuVoList) && UacConstant.MENU_ROOT.equals(menuVoList.get(0).getMenuCode())) {
menuVoList = menuVoList.get(0).getSubMenu();
}
loginRespDto.setLoginAuthDto(loginAuthDto);
loginRespDto.setMenuList(menuVoList);
return loginRespDto;
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacUserServiceImpl method queryUserMenuDtoData.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UserMenuDto> queryUserMenuDtoData(LoginAuthDto authResDto) {
// 返回的结果集
List<UserMenuDto> list = Lists.newArrayList();
// 该用户下所有的菜单集合
List<MenuVo> menuList;
Long userId = authResDto.getUserId();
List<Long> ownerMenuIdList = Lists.newArrayList();
Preconditions.checkArgument(!PubUtils.isNull(authResDto, userId), "无访问权限");
// 查询该用户下所有的菜单Id集合
UacUserMenu query = new UacUserMenu();
query.setUserId(userId);
List<UacUserMenu> userMenus = uacUserMenuMapper.select(query);
for (UacUserMenu userMenu : userMenus) {
if (PublicUtil.isEmpty(userMenu.getUserId())) {
continue;
}
ownerMenuIdList.add(userMenu.getMenuId());
}
// 判断是否为admin用户 如果是则返回所有菜单, 如果不是走下面流程
menuList = uacMenuService.getMenuVoList(userId, 1L);
for (MenuVo menuVo : menuList) {
// 一级菜单
UserMenuDto userMenuDto = new UserMenuDto();
userMenuDto.setFistMenuIcon(menuVo.getIcon());
userMenuDto.setFistMenuName(menuVo.getMenuName());
List<MenuVo> sub2Menu = menuVo.getSubMenu();
List<UserMenuChildrenDto> children = Lists.newArrayList();
for (MenuVo vo2 : sub2Menu) {
// 二级菜单 如果没有子节直接放入
if (!vo2.isHasMenu()) {
UserMenuChildrenDto userMenuChildrenDto = new UserMenuChildrenDto(vo2);
// 判断是否含有该菜单, 含有为true, 不含有为false
if (ownerMenuIdList.contains(vo2.getId())) {
userMenuChildrenDto.setChecked(true);
}
children.add(userMenuChildrenDto);
continue;
}
// 如果二级节点有子节继续循环三级菜单
List<MenuVo> sub3Menu = vo2.getSubMenu();
for (MenuVo vo3 : sub3Menu) {
UserMenuChildrenDto dto = new UserMenuChildrenDto(vo3);
// 判断是否含有该菜单, 含有为true, 不含有为false
if (ownerMenuIdList.contains(vo3.getId())) {
dto.setChecked(true);
}
children.add(dto);
}
}
userMenuDto.setChildren(children);
list.add(userMenuDto);
}
return list;
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacUserServiceImpl method checkUserMenuList.
/**
* 校验数据是否合法
*
* @param menuIdList 需要操作的菜单Id集合
* @param authResDto 登录用户
* @param uacUserMenuList 需要插入的记录
*/
private void checkUserMenuList(List<Long> menuIdList, LoginAuthDto authResDto, List<UacUserMenu> uacUserMenuList) {
List<MenuVo> currentUserMenuVoList = uacMenuService.findAllMenuListByAuthResDto(authResDto);
List<Long> currentUserMenuIdList = Lists.newArrayList();
for (MenuVo menuVo : currentUserMenuVoList) {
Long menuId = menuVo.getId();
if (PublicUtil.isEmpty(menuId)) {
continue;
}
currentUserMenuIdList.add(menuId);
}
Preconditions.checkArgument(currentUserMenuIdList.containsAll(menuIdList), "参数异常");
// TODO 预留一个过滤已失效菜单的接口
for (Long menuId : menuIdList) {
if (uacMenuService.checkMenuHasChildMenu(menuId)) {
logger.error(" 选择菜单不是根目录 menuId= {}", menuId);
throw new UacBizException(ErrorCodeEnum.UAC10013010, menuId);
}
UacUserMenu uacUserMenu = new UacUserMenu();
uacUserMenu.setUserId(authResDto.getUserId());
uacUserMenu.setMenuId(menuId);
uacUserMenuList.add(uacUserMenu);
}
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacMenuServiceImpl method getMenuVoList.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<MenuVo> getMenuVoList(Long userId, Long applicationId) {
// 1.查询该用户下所有的菜单列表
List<MenuVo> menuVoList = Lists.newArrayList();
List<UacMenu> menuList;
Set<UacMenu> menuSet = Sets.newHashSet();
// 如果是admin则返回所有的菜单
if (userId == 1L) {
// 1.1 查询该用户下所有的菜单列表
UacMenu uacMenuQuery = new UacMenu();
uacMenuQuery.setStatus(UacMenuStatusEnum.ENABLE.getType());
uacMenuQuery.setApplicationId(applicationId);
uacMenuQuery.setOrderBy(" level asc,number asc");
menuList = uacMenuMapper.selectMenuList(uacMenuQuery);
} else {
// 1.2查询该用户下所有的菜单列表
menuVoList = uacMenuMapper.findMenuVoListByUserId(userId);
if (PublicUtil.isEmpty(menuVoList)) {
return null;
}
Set<Long> ids = Sets.newHashSet();
for (final MenuVo menuVo : menuVoList) {
ids.add(menuVo.getId());
}
List<UacMenu> ownMenuList = this.getMenuList(ids);
// 查出所有含有菜单的菜单信息
UacMenu uacMenu = new UacMenu();
uacMenu.setStatus(UacMenuStatusEnum.ENABLE.getType());
List<UacMenu> allMenuList = this.selectMenuList(uacMenu);
Map<Long, UacMenu> map = Maps.newHashMap();
for (final UacMenu menu : allMenuList) {
map.put(menu.getId(), menu);
}
for (final UacMenu menu : ownMenuList) {
getPid(menuSet, menu, map);
}
menuList = new ArrayList<>(menuSet);
}
List<MenuVo> list = getMenuVo(menuList);
if (PublicUtil.isNotEmpty(menuVoList)) {
list.addAll(menuVoList);
}
// 2.递归成树
return TreeUtil.getChildMenuVos(list, 0L);
}
use of com.paascloud.provider.model.vo.MenuVo in project paascloud-master by paascloud.
the class UacMenuServiceImpl method findAllMenuListByAuthResDto.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<MenuVo> findAllMenuListByAuthResDto(LoginAuthDto authResDto) {
List<MenuVo> voList = Lists.newArrayList();
Preconditions.checkArgument(authResDto != null, "无权访问");
if (!GlobalConstant.Sys.SUPER_MANAGER_LOGIN_NAME.equals(authResDto.getLoginName())) {
voList = uacMenuMapper.findMenuVoListByUserId(authResDto.getUserId());
} else {
UacMenu uacMenuQuery = new UacMenu();
// 查询启用的菜单
uacMenuQuery.setStatus(UacMenuStatusEnum.ENABLE.getType());
uacMenuQuery.setOrderBy(" level asc,number asc");
List<UacMenu> list = uacMenuMapper.select(uacMenuQuery);
for (UacMenu uacMenu : list) {
MenuVo menuVo = new MenuVo();
BeanUtils.copyProperties(uacMenu, menuVo);
voList.add(menuVo);
}
}
return voList;
}
Aggregations