Search in sources :

Example 11 with UacMenu

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

the class UacMenuServiceImpl method listMenuListByRoleId.

@Override
public List<UacMenu> listMenuListByRoleId(Long roleId) {
    List<UacMenu> menuList = uacMenuMapper.listMenuListByRoleId(roleId);
    List<UacMenu> addMenuList = Lists.newArrayList();
    if (PublicUtil.isNotEmpty(menuList)) {
        for (UacMenu uacMenu : menuList) {
            getMenuList(addMenuList, uacMenu.getPid());
        }
    }
    menuList.addAll(addMenuList);
    return new ArrayList<>(new HashSet<>(menuList));
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu)

Example 12 with UacMenu

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

the class UacMenuMainController method saveMenu.

/**
 * 新增菜单.
 *
 * @param uacMenuAddDto the uac menu add dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增菜单")
@LogAnnotation
public Wrapper saveMenu(@ApiParam(name = "saveMenu", value = "保存菜单") @RequestBody UacEditMenuDto uacMenuAddDto) {
    UacMenu uacMenu = new UacMenu();
    LoginAuthDto loginAuthDto = getLoginAuthDto();
    BeanUtils.copyProperties(uacMenuAddDto, uacMenu);
    uacMenuService.saveUacMenu(uacMenu, loginAuthDto);
    return WrapMapper.ok();
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) LogAnnotation(com.paascloud.core.annotation.LogAnnotation) ApiOperation(io.swagger.annotations.ApiOperation)

Example 13 with UacMenu

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

the class UacMenuServiceImpl method deleteUacMenuById.

@Override
public int deleteUacMenuById(Long id, LoginAuthDto loginAuthDto) {
    Preconditions.checkArgument(id != null, "菜单id不能为空");
    int result;
    // 获取当前菜单信息
    UacMenu uacMenuQuery = new UacMenu();
    uacMenuQuery.setId(id);
    uacMenuQuery = mapper.selectOne(uacMenuQuery);
    if (PublicUtil.isEmpty(uacMenuQuery)) {
        throw new UacBizException(ErrorCodeEnum.UAC10013003, id);
    }
    // 删除菜单与角色的关联关系
    UacRoleMenu uacRoleMenu = new UacRoleMenu();
    uacRoleMenu.setMenuId(id);
    uacRoleMenuService.delete(uacRoleMenu);
    // 删除菜单
    result = uacMenuMapper.deleteByPrimaryKey(id);
    if (result < 1) {
        logger.error("删除菜单失败 menuId={}", id);
        throw new UacBizException(ErrorCodeEnum.UAC10013008, id);
    }
    // 删除权限
    // TODO 应该先查询再删除
    uacActionService.deleteByMenuId(id);
    // 修改当前删除菜单的父菜单是否是叶子节点
    UacMenu updateParentUacMenu = new UacMenu();
    updateParentUacMenu.setId(uacMenuQuery.getPid());
    updateParentUacMenu.setLeaf(MenuConstant.MENU_LEAF_YES);
    // 是二三级
    if (Objects.equals(MenuConstant.MENU_LEVEL_TWO, uacMenuQuery.getLevel()) || Objects.equals(MenuConstant.MENU_LEVEL_THREE, uacMenuQuery.getLevel())) {
        // 查询是否是叶子节点
        int count = uacMenuMapper.selectMenuChildCountByPid(uacMenuQuery.getPid());
        if (count == 0) {
            uacMenuMapper.updateByPrimaryKeySelective(updateParentUacMenu);
        }
    }
    return result;
}
Also used : UacRoleMenu(com.paascloud.provider.model.domain.UacRoleMenu) UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 14 with UacMenu

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

the class UacMenuServiceImpl method getMenuList.

private List<UacMenu> getMenuList(List<UacMenu> uacMenuList, Long menuId) {
    UacMenu uacMenu = uacMenuMapper.selectByPrimaryKey(menuId);
    if (uacMenu != null) {
        Long pid = uacMenu.getPid();
        if (pid != null) {
            uacMenuList.add(uacMenu);
            getMenuList(uacMenuList, pid);
        }
    }
    return uacMenuList;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu)

Example 15 with UacMenu

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

the class UacMenuServiceImpl method updateUacMenuStatusById.

@Override
public void updateUacMenuStatusById(UacMenuStatusDto uacMenuStatusDto, LoginAuthDto loginAuthDto) {
    Long id = uacMenuStatusDto.getId();
    String status = uacMenuStatusDto.getStatus();
    Preconditions.checkArgument(id != null, "菜单ID不能为空");
    Preconditions.checkArgument(StringUtils.isNotEmpty(status), "菜单状态不能为空");
    UacMenu uacMenuQuery = this.selectByKey(id);
    if (MenuConstant.MENU_LEVEL_ROOT.equals(uacMenuQuery.getLevel())) {
        throw new UacBizException(ErrorCodeEnum.UAC10013007);
    }
    // 要处理的菜单集合
    List<UacMenu> menuList = Lists.newArrayList();
    int result;
    if (status.equals(UacMenuStatusEnum.DISABLE.getType())) {
        // 获取菜单以及子菜单
        menuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.ENABLE.getType());
        // 禁用菜单以及子菜单
        result = this.disableMenuList(menuList, loginAuthDto);
    } else {
        // 获取菜单、其子菜单以及父菜单
        UacMenu uacMenu = new UacMenu();
        uacMenu.setPid(id);
        result = this.selectCount(uacMenu);
        // 此菜单含有子菜单
        if (result > 0) {
            menuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.DISABLE.getType());
        }
        List<UacMenu> menuListTemp = this.getAllParentMenuByMenuId(id);
        for (UacMenu menu : menuListTemp) {
            if (!menuList.contains(menu)) {
                menuList.add(menu);
            }
        }
        // 启用菜单、其子菜单以及父菜单
        result = this.enableMenuList(menuList, loginAuthDto);
    }
    if (result < 1) {
        throw new UacBizException(ErrorCodeEnum.UAC10013006, id);
    }
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

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