| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.enums.RoleLevelStatus; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.execption.EntityExistException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.param.MenuParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.bo.MenuNode; |
| | | import com.sandu.ximon.dao.domain.AdminRoleRelation; |
| | | import com.sandu.ximon.dao.domain.Menu; |
| | | import com.sandu.ximon.dao.domain.Role; |
| | | import com.sandu.ximon.dao.domain.RoleMenuRelation; |
| | | import com.sandu.ximon.dao.mapper.AdminRoleRelationMapper; |
| | | import com.sandu.ximon.dao.mapper.MenuMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * 获取角色下的菜单 |
| | | */ |
| | | public List<Menu> listByRoleIds(List<Long> roleIdList) { |
| | | List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class).in(RoleMenuRelation::getRoleId, roleIdList).select(RoleMenuRelation::getMenuId)) |
| | | List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class) |
| | | .in(RoleMenuRelation::getRoleId, roleIdList).select(RoleMenuRelation::getMenuId)) |
| | | .stream().map(RoleMenuRelation::getMenuId).distinct().collect(Collectors.toList()); |
| | | if (CollectionUtil.isEmpty(menuIdList)) { |
| | | return null; |
| | |
| | | throw new BusinessException("找不到菜单信息"); |
| | | } |
| | | |
| | | if (one.getPid() == 0 && param.getPid() != 0) { |
| | | throw new BusinessException("目录已是最顶层菜单,无法设置上级目录 !"); |
| | | } |
| | | |
| | | List<Role> roles = SpringContextHolder.getBean(RoleService.class).listByAdminId(SecurityUtils.getUserId()); |
| | | Integer roleLevel = roles.stream().map(Role::getLevel).min(Integer::compareTo).orElse(RoleLevelStatus.COMMON.getCode()); |
| | | if (!RoleLevelStatus.SUPER.getCode().equals(roleLevel)) { |
| | |
| | | |
| | | Menu menu = new Menu(); |
| | | BeanUtils.copyProperties(param, menu); |
| | | menu.setType(one.getType()); |
| | | menu.setId(menuId); |
| | | return updateById(menu); |
| | | } |