Commit 0b6e172a by 何文超

更新goods包

parent 1b550001
package com.gic.plug.web.controller.goods;
import java.util.*;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.goods.api.dto.GoodsDomainDTO;
import com.gic.goods.api.service.GoodsDomainApiService;
import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.goods.GoodsChannelVO;
import com.gic.plug.web.vo.goods.GoodsDomainVO;
@RestController
public class GoodsDomainController {
private static Map<String, String> channelCodeAndName;
static {
channelCodeAndName = new HashMap<>();
channelCodeAndName.put(Constant.CHANNEL_CODE_ERP, "ERP");
channelCodeAndName.put(Constant.CHANNEL_CODE_WEIMOB, "微盟");
channelCodeAndName.put(Constant.CHANNEL_CODE_MALL, "GIC微商城");
}
@Autowired
private GoodsDomainApiService goodsDomainApiService;
/**
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
* @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/
@RequestMapping("/get-all-goods-domain-list")
private RestResponse getAllGoodsDomianListWith() {
ServiceResponse<List<GoodsDomainDTO>> serviceResponse = goodsDomainApiService.listAll(Constant.TEST_ENTERPRISE_ID);
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
List<GoodsDomainDTO> goodsDomainDTOList = serviceResponse.getResult();
Map<String, List<GoodsDomainDTO>> map = new TreeMap<>();
if (CollectionUtils.isEmpty(goodsDomainDTOList)) {
return RestResponse.success(Collections.EMPTY_LIST);
}
for (GoodsDomainDTO goodsDomainDTO : goodsDomainDTOList) {
if (CollectionUtils.isNotEmpty(goodsDomainDTO.getChannels())){
for (String channelCode : goodsDomainDTO.getChannels()) {
map.putIfAbsent(channelCode, new ArrayList<>());
map.get(channelCode).add(goodsDomainDTO);
}
}
}
List<GoodsChannelVO> resultList = new ArrayList<>();
for (Map.Entry<String, List<GoodsDomainDTO>> entry : map.entrySet()) {
GoodsChannelVO goodsChannelVO = new GoodsChannelVO();
goodsChannelVO.setChannelCode(entry.getKey());
goodsChannelVO.setChannelName(channelCodeAndName.get(entry.getKey()));
goodsChannelVO.setGoodsDomainList(new ArrayList<>());
for (GoodsDomainDTO goodsDomainDTO : entry.getValue()) {
GoodsDomainVO goodsDomainVO = new GoodsDomainVO();
goodsDomainVO.setDomainCode(goodsDomainDTO.getCode());
goodsDomainVO.setDomainId(goodsDomainDTO.getGoodsDomainId());
goodsDomainVO.setDomainName(goodsDomainDTO.getName());
goodsChannelVO.getGoodsDomainList().add(goodsDomainVO);
}
resultList.add(goodsChannelVO);
}
return RestResponse.success(resultList);
}
}
package com.gic.plug.web.qo.goods;
public class GoodsQO {
}
package com.gic.plug.web.vo.goods;
import java.util.List;
public class GoodsChannelVO {
private String channelCode;
private String channelName;
private List<GoodsDomainVO> goodsDomainList;
public String getChannelCode() {
return channelCode;
}
public void setChannelCode(String channelCode) {
this.channelCode = channelCode;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
public List<GoodsDomainVO> getGoodsDomainList() {
return goodsDomainList;
}
public void setGoodsDomainList(List<GoodsDomainVO> goodsDomainList) {
this.goodsDomainList = goodsDomainList;
}
}
package com.gic.plug.web.vo.goods;
public class GoodsDomainVO {
private String domainCode;
private String domainName;
private Long domainId;
public String getDomainCode() {
return domainCode;
}
public void setDomainCode(String domainCode) {
this.domainCode = domainCode;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
}
......@@ -31,4 +31,8 @@
<dubbo:reference interface="com.gic.store.service.StoreStrategyApiService" id="storeStrategyApiService" timeout="60000" retries="0"/>
<dubbo:reference interface="com.gic.widget.screening.api.service.EsScreeningInitService" id="esScreeningInitService" timeout="60000" retries="0"/>
<dubbo:reference interface="com.gic.widget.screening.api.service.EsScreeningTemplateService" id="esScreeningTemplateService" timeout="60000" retries="0"/>
<!-- 商品 -->
<dubbo:reference interface="com.gic.goods.api.service.GoodsDomainApiService" id="goodsDomainApiService" timeout="60000" retries="0" />
<!-- -->
</beans>
\ No newline at end of file
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