Authored by mali

根据sku列表 查询商品的信息

package com.yohoufo.product.controller;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.core.config.ConfigReader;
import com.yoho.error.exception.ServiceException;
import com.yoho.tools.docs.ApiOperation;
... ... @@ -881,4 +882,14 @@ public class ProductController {
LOG.info("in method=ufo.product.info.data productId = {}", productId);
return productService.queryProductInfo(productId);
}
@ApiOperation(name = "ufo.product.storageList.data", desc = "sku信息")
@RequestMapping(params = "method=ufo.product.storageList.data")
public List<StorageDataResp> queryStorageListInfo(@RequestParam(value = "storageIdList") List<Integer> storageIdList) {
LOG.info("in method=ufo.product.storageList.data storageIdList Is {}", storageIdList);
if (CollectionUtils.isEmpty(storageIdList)) {
return Lists.newArrayList();
}
return productService.queryStorageListInfo(storageIdList);
}
}
\ No newline at end of file
... ...
... ... @@ -123,4 +123,6 @@ public interface ProductService {
* @return
*/
ProductInfo queryProductInfo(Integer productId);
List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList);
}
... ...
... ... @@ -1926,4 +1926,47 @@ public class ProductServiceImpl implements ProductService {
return resp;
}
public List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList) {
List<StorageDataResp> respList = new ArrayList<>();
List<Storage> storageList = storageMapper.selectByIds(storageIdList);
if (CollectionUtils.isEmpty(storageList)) {
return null;
}
/*List<Integer> sizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
List<Size> sizes = sizeMapper.selectByIds(sizeIdList);
List<Integer> goodsIdList = storageList.stream().map(Storage::getGoodsId).collect(Collectors.toList());
List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList);
List<Integer> productIdList = storageList.stream().map(Storage::getProductId).collect(Collectors.toList());
List<Product> products = productMapper.selectByIds(productIdList);
StorageDataResp resp = new StorageDataResp();
storageList.forEach(item -> {
GoodsSize goodsSize = new GoodsSize();
goodsSize.setSizeId(storage.getSizeId());
if (size != null) {
goodsSize.setSizeName(size.getSizeName());
}
resp.setSize(goodsSize);
resp.setColorId(goods.getColorId().toString());
resp.setColorName(StringUtils.isEmpty(goods.getGoodsName()) ? goods.getColorName() : goods.getGoodsName());
resp.setImageUrl(goods.getColorImage());
if (product != null) {
resp.setProductId(product.getId());
resp.setProductName(product.getProductName());
resp.setStatus(product.getShelveStatus());
}
});*/
return respList;
}
}
... ...