优化查询组站点树状列表接口响应速度
This commit is contained in:
parent
135a5e295d
commit
2698e9ff29
@ -52,7 +52,11 @@ public class ProjectDataIsolationInterceptor implements HandlerInterceptor {
|
||||
return true;
|
||||
}
|
||||
//当前项目信息
|
||||
ProjectInfo projectInfo = ProjectInfo.builder().build();
|
||||
ProjectInfo projectInfo = ProjectInfo.builder()
|
||||
.projectId("")
|
||||
.projectIdList(new ArrayList<>())
|
||||
.projectAdminId("")
|
||||
.build();
|
||||
//获取cookie
|
||||
Cookie[] requestCookies = request.getCookies();
|
||||
//获取cookie中的projectIds(父项目及其子项目id),projectId(当前项目id),userId(当前管理员id)
|
||||
|
@ -65,7 +65,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
List<GGroups> list = new LambdaQueryChainWrapper<>(gGroupsMapper).select(GGroups::getId, GGroups::getName, GGroups::getIcon,
|
||||
GGroups::getTag, GGroups::getParentId, GGroups::getProjectId, GGroups::getProjectName,
|
||||
GGroups::getOrderNum, GGroups::getSpace)
|
||||
.in(Objects.nonNull(ProjectHolder.getProjectInfo().getProjectIdList())&&gGroups.getProjectId()==null,
|
||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty()&&gGroups.getProjectId()==null,
|
||||
GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.eq(gGroups.getProjectId()!=null, GGroups::getProjectId, gGroups.getProjectId())
|
||||
.list();
|
||||
@ -130,15 +130,20 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
Map<Long, GGroups> map = new HashMap<>();
|
||||
//根组列表
|
||||
List<GGroups> roots = new ArrayList<>();
|
||||
//所有站点列表
|
||||
|
||||
List<GGroupSiteVo> gGroupSiteAllList = selectGGroupsAllListSites(new GGroups());
|
||||
gGroupSiteAllList.forEach(System.err::println);
|
||||
|
||||
for (GGroups group : groupsList) {
|
||||
//查询组的直接子站点列表
|
||||
//TODO 优化为查询出所有站点列表,内存中处理
|
||||
GGroups gGroups = new GGroups();
|
||||
gGroups.setParentId(group.getId());
|
||||
List<GGroupSiteVo> gGroupSiteVoList = gGroupsMapper.selectGGroupsSiteList(gGroups);
|
||||
//过滤全部站点列表找到当前组下面的所有站点
|
||||
List<GGroupSiteVo> currentGroupSiteList = gGroupSiteAllList.stream()
|
||||
.filter(site -> site.getParentId().equals(group.getId()))
|
||||
.collect(Collectors.toList());
|
||||
//将子站点列表添加到组对象中
|
||||
List<GGroups> childrenList= group.getChildren();
|
||||
gGroupSiteVoList.forEach(site->{
|
||||
currentGroupSiteList.forEach(site->{
|
||||
GGroups gGroups1 = new GGroups();
|
||||
gGroups1.setId(site.getId());
|
||||
gGroups1.setName(site.getName());
|
||||
@ -155,6 +160,20 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
//构建组树状结构
|
||||
return combinationGroupsTree(groupsList, map, roots);
|
||||
}
|
||||
/**
|
||||
* 查询项目下全部站点
|
||||
*/
|
||||
|
||||
public List<GGroupSiteVo> selectGGroupsAllListSites(GGroups gGroups) {
|
||||
MPJLambdaWrapper<GSiteGroups> gSiteGroupsMPJLambdaWrapper = new MPJLambdaWrapper<GSiteGroups>()
|
||||
.select(GSiteGroups::getId, GSiteGroups::getParentId, GSiteGroups::getSiteId)
|
||||
.select(GSites::getName, GSites::getIcon, GSites::getType, GSites::getSpace, GSites::getSpaceValue)
|
||||
.leftJoin(GGroups.class, GGroups::getId, GSiteGroups::getParentId)
|
||||
.leftJoin(GSites.class, GSites::getId, GSiteGroups::getSiteId)
|
||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty(),GGroups::getProjectId,ProjectHolder.getProjectInfo().getProjectIdList());
|
||||
return gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增组
|
||||
@ -227,7 +246,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
.select(GGroups::getId, GGroups::getName, GGroups::getParentId, GGroups::getIcon,GGroups::getTag,
|
||||
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
|
||||
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
|
||||
.in(Objects.nonNull(ProjectHolder.getProjectInfo().getProjectIdList()),GGroups::getProjectId,
|
||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty(),GGroups::getProjectId,
|
||||
ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.list();
|
||||
List<GGroups> gGroupsList = buildTreeSite(groupSiteTreeList);
|
||||
|
Loading…
x
Reference in New Issue
Block a user