Commit 92ec26dc by guojuxing

品牌添加共享标志

parent 9ec11082
package com.gic.plug.web.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.gic.plug.web.vo.widget.StoreWidgetInterfaceVO;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.plug.web.vo.widget.StoreWidgetInterfaceShareVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -31,6 +32,8 @@ public class StoreBrandController {
@Autowired
private StoreBrandApiService storeBrandApiService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@RequestMapping("/list-store-brand")
public RestResponse listStoreBrand(String search) {
......@@ -41,10 +44,41 @@ public class StoreBrandController {
serviceResponse.getResult(),
StoreESFieldsEnum.STOREBRANDIDLIST.getField());
List<StoreWidgetInterfaceVO> voList = new ArrayList<>();
List<StoreWidgetInterfaceShareVO> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(list)) {
//共享类型
List<Integer> brandIdList = list.stream().filter(e -> Objects.equals(e.getType(), 2))
.mapToInt(e -> e.getStoreBrandId())
.boxed()
.collect(Collectors.toList());
Map<Integer, String> enterpriseMap = new HashMap<>();
ServiceResponse<List<StoreBrandDTO>> brandResponse = storeBrandApiService.listAllStoreBrandInfoByIds(brandIdList);
if (brandResponse.isSuccess() && CollectionUtils.isNotEmpty(brandResponse.getResult())) {
List<StoreBrandDTO> brandList = brandResponse.getResult();
List<Integer> enterpriseIdList = brandList.stream()
.filter(e -> Objects.equals(e.getType(), 1))
.mapToInt(e -> e.getEnterpriseId()).boxed()
.collect(Collectors.toList());
ServiceResponse<List<EnterpriseDTO>> enterpriseResponse = enterpriseApiService.listEnterpriseByIds(enterpriseIdList);
if (enterpriseResponse.isSuccess()) {
enterpriseMap = enterpriseResponse.getResult().stream().collect(Collectors.toMap(e -> e.getEnterpriseId(), e -> e.getEnterpriseName()));
}
}
Map<Integer, String> finalEnterpriseMap = enterpriseMap;
voList = list.stream()
.map(e -> new StoreWidgetInterfaceVO().setLabel(e.getStoreBrandName()).setValue(e.getStoreBrandId().toString()))
.map(e -> {
StoreWidgetInterfaceShareVO vo = new StoreWidgetInterfaceShareVO();
vo.setLabel(e.getStoreBrandName());
vo.setValue(e.getStoreBrandId().toString());
//共享类型
if (Objects.equals(e.getType(), 2)) {
vo.setEnterpriseName(finalEnterpriseMap.get(e.getEnterpriseId()));
}
return vo;
})
.collect(Collectors.toList());
}
return RestResponse.success(voList);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment