|
|
@ -1,16 +1,24 @@ |
|
|
package com.project.information.domain.service.impl; |
|
|
package com.project.information.domain.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.project.base.domain.result.Result; |
|
|
import com.project.base.domain.result.Result; |
|
|
|
|
|
import com.project.base.domain.utils.TreeUtils; |
|
|
import com.project.information.domain.dto.BusinessGroupDTO; |
|
|
import com.project.information.domain.dto.BusinessGroupDTO; |
|
|
|
|
|
import com.project.information.domain.dto.ProductLineDTO; |
|
|
import com.project.information.domain.entity.BusinessGroupEntity; |
|
|
import com.project.information.domain.entity.BusinessGroupEntity; |
|
|
import com.project.information.domain.param.BusinessGroupParam; |
|
|
import com.project.information.domain.param.BusinessGroupParam; |
|
|
|
|
|
import com.project.information.domain.param.ProductLineParam; |
|
|
|
|
|
import com.project.information.domain.service.GetTreeListProductLineDomainService; |
|
|
import com.project.information.domain.service.SearchBusinessGroupDomainService; |
|
|
import com.project.information.domain.service.SearchBusinessGroupDomainService; |
|
|
import com.project.information.mapper.BusinessGroupMapper; |
|
|
import com.project.information.mapper.BusinessGroupMapper; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Optional; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
@ -18,6 +26,9 @@ public class SearchBusinessGroupDomainServiceImpl implements SearchBusinessGroup |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private BusinessGroupMapper businessGroupMapper; |
|
|
private BusinessGroupMapper businessGroupMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GetTreeListProductLineDomainService getTreeListProductLineDomainService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<List<BusinessGroupDTO>> list(BusinessGroupParam param) throws Exception { |
|
|
public Result<List<BusinessGroupDTO>> list(BusinessGroupParam param) throws Exception { |
|
|
LambdaQueryWrapper<BusinessGroupEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<BusinessGroupEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
@ -26,4 +37,26 @@ public class SearchBusinessGroupDomainServiceImpl implements SearchBusinessGroup |
|
|
.map(entity -> entity.toDTO(BusinessGroupDTO::new)) |
|
|
.map(entity -> entity.toDTO(BusinessGroupDTO::new)) |
|
|
.collect(Collectors.toList())); |
|
|
.collect(Collectors.toList())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result<List<BusinessGroupDTO>> treeList(BusinessGroupParam param) throws Exception { |
|
|
|
|
|
List<BusinessGroupDTO> businessGroupDTOList = list(param).getData(); |
|
|
|
|
|
|
|
|
|
|
|
//获取树形产品线
|
|
|
|
|
|
Result<List<ProductLineDTO>> productLineListResult = getTreeListProductLineDomainService.treeList(new ProductLineParam()); |
|
|
|
|
|
List<ProductLineDTO> productLineList = productLineListResult.getData(); |
|
|
|
|
|
|
|
|
|
|
|
Map<Long, List<ProductLineDTO>> productLineMap = Optional.ofNullable(productLineList) |
|
|
|
|
|
.orElse(new ArrayList<>()) |
|
|
|
|
|
.stream() |
|
|
|
|
|
.filter(dto -> ObjectUtil.isNotEmpty(dto.getBusinessId())) |
|
|
|
|
|
.collect(Collectors.groupingBy(ProductLineDTO::getBusinessId)); |
|
|
|
|
|
|
|
|
|
|
|
for (BusinessGroupDTO businessGroupDTO : businessGroupDTOList) { |
|
|
|
|
|
List<ProductLineDTO> productLineDTOS = productLineMap.getOrDefault(businessGroupDTO.getId(), new ArrayList<>()); |
|
|
|
|
|
businessGroupDTO.setChildrenList(productLineDTOS); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Result.success(businessGroupDTOList); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|