Search in sources :

Example 16 with UacMenu

use of com.paascloud.provider.model.domain.UacMenu 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);
}
Also used : MenuVo(com.paascloud.provider.model.vo.MenuVo) ViewMenuVo(com.paascloud.provider.model.vo.ViewMenuVo) UacMenu(com.paascloud.provider.model.domain.UacMenu) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with UacMenu

use of com.paascloud.provider.model.domain.UacMenu 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;
}
Also used : MenuVo(com.paascloud.provider.model.vo.MenuVo) ViewMenuVo(com.paascloud.provider.model.vo.ViewMenuVo) UacMenu(com.paascloud.provider.model.domain.UacMenu) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with UacMenu

use of com.paascloud.provider.model.domain.UacMenu in project paascloud-master by paascloud.

the class UacMenuServiceImpl method getAllParentMenuByMenuId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UacMenu> getAllParentMenuByMenuId(Long menuId) {
    UacMenu uacMenuQuery = new UacMenu();
    uacMenuQuery.setId(menuId);
    uacMenuQuery = mapper.selectOne(uacMenuQuery);
    List<UacMenu> uacMenuList = Lists.newArrayList();
    uacMenuList = buildParentNote(uacMenuList, uacMenuQuery);
    return uacMenuList;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UacMenu (com.paascloud.provider.model.domain.UacMenu)18 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)6 Transactional (org.springframework.transaction.annotation.Transactional)6 ViewMenuVo (com.paascloud.provider.model.vo.ViewMenuVo)4 MenuVo (com.paascloud.provider.model.vo.MenuVo)3 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 UacRoleMenu (com.paascloud.provider.model.domain.UacRoleMenu)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ModelMapper (org.modelmapper.ModelMapper)1