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));
}
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();
}
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;
}
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;
}
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);
}
}
Aggregations