Search in sources :

Example 1 with UacMenu

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

the class UacMenuServiceImpl method getAllChildMenuByMenuId.

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

Example 2 with UacMenu

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

the class UacMenuServiceImpl method getViewVoById.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ViewMenuVo getViewVoById(Long id) {
    Preconditions.checkArgument(id != null, "菜单ID不能为空");
    UacMenu menu = uacMenuMapper.selectByPrimaryKey(id);
    if (menu == null) {
        logger.error("找不到菜单信息id={}", id);
        throw new UacBizException(ErrorCodeEnum.UAC10013003, id);
    }
    // 获取父级菜单信息
    UacMenu parentMenu = uacMenuMapper.selectByPrimaryKey(menu.getPid());
    ModelMapper modelMapper = new ModelMapper();
    ViewMenuVo menuVo = modelMapper.map(menu, ViewMenuVo.class);
    if (parentMenu != null) {
        menuVo.setParentMenuName(parentMenu.getMenuName());
    }
    return menuVo;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) ViewMenuVo(com.paascloud.provider.model.vo.ViewMenuVo) ModelMapper(org.modelmapper.ModelMapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with UacMenu

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

the class UacMenuServiceImpl method getPid.

private void getPid(Set<UacMenu> menuSet, UacMenu menu, Map<Long, UacMenu> map) {
    UacMenu parent = map.get(menu.getPid());
    if (parent != null && parent.getId() != 0L) {
        menuSet.add(parent);
        getPid(menuSet, parent, map);
    }
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu)

Example 4 with UacMenu

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

the class UacMenuServiceImpl method disableMenuList.

@Override
public int disableMenuList(List<UacMenu> menuList, LoginAuthDto loginAuthDto) {
    UacMenu uacMenuUpdate = new UacMenu();
    int sum = 0;
    for (UacMenu menu : menuList) {
        uacMenuUpdate.setId(menu.getId());
        uacMenuUpdate.setVersion(menu.getVersion() + 1);
        uacMenuUpdate.setStatus(UacMenuStatusEnum.DISABLE.getType());
        uacMenuUpdate.setLastOperator(loginAuthDto.getLoginName());
        uacMenuUpdate.setLastOperatorId(loginAuthDto.getUserId());
        uacMenuUpdate.setUpdateTime(new Date());
        int result = mapper.updateByPrimaryKeySelective(uacMenuUpdate);
        if (result > 0) {
            sum += 1;
        } else {
            throw new UacBizException(ErrorCodeEnum.UAC10013005, menu.getId());
        }
    }
    return sum;
}
Also used : UacMenu(com.paascloud.provider.model.domain.UacMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 5 with UacMenu

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

the class UacMenuServiceImpl method saveUacMenu.

@Override
public int saveUacMenu(UacMenu menu, LoginAuthDto loginAuthDto) {
    Long pid = menu.getPid();
    menu.setUpdateInfo(loginAuthDto);
    UacMenu parentMenu = mapper.selectByPrimaryKey(pid);
    if (PublicUtil.isEmpty(parentMenu)) {
        throw new UacBizException(ErrorCodeEnum.UAC10013001, pid);
    }
    if (menu.isNew()) {
        UacMenu updateMenu = new UacMenu();
        menu.setLevel(parentMenu.getLevel() + 1);
        updateMenu.setLeaf(MenuConstant.MENU_LEAF_NO);
        updateMenu.setId(pid);
        Long menuId = super.generateId();
        menu.setId(menuId);
        int result = mapper.updateByPrimaryKeySelective(updateMenu);
        if (result < 1) {
            throw new UacBizException(ErrorCodeEnum.UAC10013002, menuId);
        }
        menu.setStatus(UacMenuStatusEnum.ENABLE.getType());
        menu.setCreatorId(loginAuthDto.getUserId());
        menu.setCreator(loginAuthDto.getUserName());
        menu.setLastOperatorId(loginAuthDto.getUserId());
        menu.setLastOperator(loginAuthDto.getUserName());
        // 新增的菜单是叶子节点
        menu.setLeaf(MenuConstant.MENU_LEAF_YES);
        return uacMenuMapper.insertSelective(menu);
    } else {
        return uacMenuMapper.updateByPrimaryKeySelective(menu);
    }
}
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