Commit fa2417a1 by zhouhaibao

[+]品牌处理

1 parent 60a64ac9
......@@ -38,6 +38,8 @@ import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.LinkedHashMap;
import java.util.function.Function;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -219,11 +221,19 @@ public class MerchantAnalysisController {
if (merchantDetailResponse != null) {
itemResponse.setMainBrands(
merchantDetailResponse.getCarBrandResponses().stream()
.collect(Collectors.toMap(
CarBrandDTO::getId, // 按 id 去重(唯一标识)
Function.identity(),
(existing, replacement) -> existing, // 保留第一个
LinkedHashMap::new
))
.values()
.stream()
.flatMap(parent ->
(parent.getChildren() != null && !parent.getChildren().isEmpty())
? parent.getChildren().stream()
.map(child -> parent.getLabel() + "-" + child.getLabel())
: Stream.of(parent.getLabel()) // 若无子品牌,保留主品牌自身
: Stream.of(parent.getLabel())
)
.collect(Collectors.joining("/"))
);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!