From a5a5da73dec49c5cd23761edad8be98cde8a3b74 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期六, 31 八月 2024 17:24:23 +0800 Subject: [PATCH] 平台调整 --- ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java | 43 +++++++++++++++++++++++++++++++------------ 1 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java index e716c53..3f33e78 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java @@ -1,6 +1,7 @@ package com.ycl.platform.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.platform.domain.entity.Platform; import com.ycl.platform.domain.form.PlatformForm; @@ -18,6 +19,8 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -43,16 +46,23 @@ public Result add(PlatformForm form) { Platform entity = PlatformForm.getEntityByForm(form, null); entity.setParentId(0); + Date now = new Date(); + entity.setCreateTime(now); + entity.setUpdateTime(now); + entity.setArea(form.getAreaList().stream().collect(Collectors.joining(","))); baseMapper.insert(entity); - if (! CollectionUtils.isEmpty(form.getDeployList())) { - List<Platform> childList = form.getDeployList().stream().map(deploy -> { - Platform child = new Platform(); - BeanUtils.copyProperties(deploy, child); - child.setParentId(entity.getId()); - return child; - }).collect(Collectors.toList()); - this.saveBatch(childList); - } +// if (! CollectionUtils.isEmpty(form.getDeployList())) { +// List<Platform> childList = form.getDeployList().stream().map(deploy -> { +// Platform child = new Platform(); +// BeanUtils.copyProperties(deploy, child); +// child.setPlatformName(entity.getPlatformName()); +// child.setParentId(entity.getId()); +// child.setCreateTime(now); +// child.setUpdateTime(now); +// return child; +// }).collect(Collectors.toList()); +// this.saveBatch(childList); +// } return Result.ok("娣诲姞鎴愬姛"); } @@ -101,9 +111,18 @@ */ @Override public Result page(PlatformQuery query) { - IPage<PlatformVO> page = PageUtil.getPage(query, PlatformVO.class); - baseMapper.getPage(page, query); - return Result.ok().data(page.getRecords()).total(page.getTotal()); + List<PlatformVO> list = baseMapper.getPage(query); + List<PlatformVO> parentList = list.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList()); + List<PlatformVO> resultList = new ArrayList<>(4); + for (PlatformVO parent : parentList) { + List<PlatformVO> childList = list.stream().filter(item -> item.getParentId().equals(parent.getId())).collect(Collectors.toList()); + + parent.setChildNum(childList.size()); + resultList.add(parent); + resultList.addAll(childList); + } + // 鍓嶇涓嶇敤灞曠ず鍒嗛〉 + return Result.ok().data(resultList).total(0); } /** -- Gitblit v1.8.0