|
@@ -5,17 +5,17 @@
|
|
|
*/
|
|
|
package com.aizuda.boot.modules.system.service.impl;
|
|
|
|
|
|
+import com.aizuda.boot.modules.system.entity.SysResource;
|
|
|
+import com.aizuda.boot.modules.system.entity.SysResourceApi;
|
|
|
+import com.aizuda.boot.modules.system.entity.enums.ResourceType;
|
|
|
import com.aizuda.boot.modules.system.entity.param.ResourceParam;
|
|
|
+import com.aizuda.boot.modules.system.entity.vo.MenuVO;
|
|
|
+import com.aizuda.boot.modules.system.entity.vo.ResourceTreeVO;
|
|
|
import com.aizuda.boot.modules.system.mapper.SysResourceMapper;
|
|
|
import com.aizuda.boot.modules.system.service.ISysResourceApiService;
|
|
|
import com.aizuda.boot.modules.system.service.ISysResourceService;
|
|
|
import com.aizuda.core.api.ApiAssert;
|
|
|
import com.aizuda.service.service.BaseServiceImpl;
|
|
|
-import com.aizuda.boot.modules.system.entity.SysResource;
|
|
|
-import com.aizuda.boot.modules.system.entity.SysResourceApi;
|
|
|
-import com.aizuda.boot.modules.system.entity.enums.ResourceType;
|
|
|
-import com.aizuda.boot.modules.system.entity.vo.MenuVO;
|
|
|
-import com.aizuda.boot.modules.system.entity.vo.ResourceTreeVO;
|
|
|
import com.aizuda.service.web.UserSession;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -27,7 +27,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 系统资源 服务实现类
|
|
@@ -63,7 +62,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
ResourceTreeVO vo = e.convert(ResourceTreeVO.class);
|
|
|
vo.setChildren(this.getChild(vo.getId(), vo.getTitle(), sysResourceList));
|
|
|
return vo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ }).toList();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,8 +70,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
*/
|
|
|
protected List<ResourceTreeVO> getChild(Long id, String parentName, List<SysResource> sysResourceList) {
|
|
|
// 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较
|
|
|
- List<SysResource> childList = sysResourceList.stream().filter(e -> Objects.equals(id, e.getPid()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<SysResource> childList = sysResourceList.stream().filter(e -> Objects.equals(id, e.getPid())).toList();
|
|
|
if (childList.isEmpty()) {
|
|
|
// 没有子节点,返回一个空 List(递归退出)
|
|
|
return null;
|
|
@@ -83,7 +81,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
vo.setParentName(parentName);
|
|
|
vo.setChildren(this.getChild(vo.getId(), vo.getTitle(), sysResourceList));
|
|
|
return vo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ }).toList();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -108,7 +106,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
}
|
|
|
return sysResourceList.stream().filter(e -> Objects.equals(0L, e.getPid()))
|
|
|
.map(e -> this.getMenuVO(e, sysResourceList))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ .toList();
|
|
|
}
|
|
|
|
|
|
protected MenuVO getMenuVO(SysResource sysResource, List<SysResource> sysResourceList) {
|
|
@@ -135,14 +133,13 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
*/
|
|
|
protected List<MenuVO> getMenuChild(Long id, List<SysResource> sysResourceList) {
|
|
|
// 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较
|
|
|
- List<SysResource> childList = sysResourceList.stream().filter(e -> Objects.equals(id, e.getPid()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<SysResource> childList = sysResourceList.stream().filter(e -> Objects.equals(id, e.getPid())).toList();
|
|
|
if (childList.isEmpty()) {
|
|
|
// 没有子节点,返回一个空 List(递归退出)
|
|
|
return null;
|
|
|
}
|
|
|
// 递归
|
|
|
- return childList.stream().map(e -> this.getMenuVO(e, sysResourceList)).collect(Collectors.toList());
|
|
|
+ return childList.stream().map(e -> this.getMenuVO(e, sysResourceList)).toList();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -162,8 +159,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
|
|
|
List<SysResourceApi> apiList = param.getApiList();
|
|
|
if (CollectionUtils.isNotEmpty(apiList)) {
|
|
|
// 移除空字符串
|
|
|
- apiList = apiList.stream().filter(t -> StringUtils.isNoneBlank(t.getUrl()) && StringUtils.isNoneBlank(t.getCode()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ apiList = apiList.stream().filter(t -> StringUtils.isNoneBlank(t.getUrl()) && StringUtils.isNoneBlank(t.getCode())).toList();
|
|
|
if (CollectionUtils.isNotEmpty(apiList)) {
|
|
|
sysResourceApiService.removeByResourceId(param.getId());
|
|
|
apiList.forEach(t -> {
|