Search in sources :

Example 1 with UacRoleMenu

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

the class UacRoleMenuServiceImpl method listByRoleId.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UacRoleMenu> listByRoleId(Long roleId) {
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleMenu roleMenu = new UacRoleMenu();
    roleMenu.setRoleId(roleId);
    return uacRoleMenuMapper.select(roleMenu);
}
Also used : UacRoleMenu(com.paascloud.provider.model.domain.UacRoleMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with UacRoleMenu

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

the class UacRoleMenuServiceImpl method deleteByRoleId.

@Override
public void deleteByRoleId(Long roleId) {
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleMenu roleMenu = new UacRoleMenu();
    roleMenu.setRoleId(roleId);
    uacRoleMenuMapper.delete(roleMenu);
}
Also used : UacRoleMenu(com.paascloud.provider.model.domain.UacRoleMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 3 with UacRoleMenu

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

the class UacRoleMenuServiceImpl method insert.

@Override
public void insert(Long roleId, Set<Long> menuIdList) {
    if (roleId == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10012001);
    }
    UacRoleMenu uacRoleMenu = new UacRoleMenu();
    uacRoleMenu.setRoleId(roleId);
    for (Long menuId : menuIdList) {
        uacRoleMenu.setMenuId(menuId);
        uacRoleMenuMapper.insertSelective(uacRoleMenu);
    }
}
Also used : UacRoleMenu(com.paascloud.provider.model.domain.UacRoleMenu) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 4 with UacRoleMenu

use of com.paascloud.provider.model.domain.UacRoleMenu 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)

Aggregations

UacRoleMenu (com.paascloud.provider.model.domain.UacRoleMenu)4 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)4 UacMenu (com.paascloud.provider.model.domain.UacMenu)1 Transactional (org.springframework.transaction.annotation.Transactional)1