Commit da8bd5f4 by zhouhaibao

[+]品牌处理

1 parent fa2417a1
...@@ -39,6 +39,7 @@ import com.rop.annotation.ServiceMethodBean; ...@@ -39,6 +39,7 @@ import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -221,6 +222,10 @@ public class MerchantAnalysisController { ...@@ -221,6 +222,10 @@ public class MerchantAnalysisController {
if (merchantDetailResponse != null) { if (merchantDetailResponse != null) {
itemResponse.setMainBrands( itemResponse.setMainBrands(
merchantDetailResponse.getCarBrandResponses().stream() merchantDetailResponse.getCarBrandResponses().stream()
// 1. 过滤掉 null 的 CarBrandDTO
.filter(Objects::nonNull)
// 2. 过滤掉 id 为 null 的(避免 toMap 报错)
.filter(carBrand -> carBrand.getId() != null)
.collect(Collectors.toMap( .collect(Collectors.toMap(
CarBrandDTO::getId, // 按 id 去重(唯一标识) CarBrandDTO::getId, // 按 id 去重(唯一标识)
Function.identity(), Function.identity(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!