Authored by zhaojun2

add productsorttemplate

... ... @@ -78,7 +78,7 @@
from product
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select id, series_id from product where id in
select id, product_name, product_code, series_id from product where id in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.product.controller;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.yohoufo.product.response.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -22,10 +23,6 @@ import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.UfoJsonUtil;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
import com.yohoufo.product.service.ProductService;
... ... @@ -46,7 +43,7 @@ public class ProductController {
@RequestMapping(params = "method=ufo.product.data")
@Cachable(expire=600)
public ApiResponse queryProductDetailById(
@RequestParam(value = "product_id", required = true) Integer productId) {
@RequestParam(value = "product_id") Integer productId) {
if (null == productId) {
return new ApiResponse(400, "product_id Is Null", null);
... ... @@ -57,19 +54,33 @@ public class ProductController {
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
@ApiOperation(name = "ufo.product.series.template", desc="商品系列列表")
@IgnoreSignature
@IgnoreSession
@RequestMapping(params = "method=ufo.product.series.template")
//@Cachable(expire=600)
public ApiResponse querySeriesTemplateData(
@RequestParam(value = "product_ids") String productIds) {
if (StringUtils.isBlank(productIds)) {
return new ApiResponse(400, "productIds Is Null", null);
}
ProductSeriesTemplateResp resp = productService.querySeriesTemplateData(productIds);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
@ApiOperation(name = "ufo.product.sort.template", desc="商品列表")
@IgnoreSignature
@IgnoreSession
@RequestMapping(params = "method=ufo.product.sort.template")
//@Cachable(expire=600)
public ApiResponse querySortTemplateData(
@RequestParam(value = "skns", required = false) String skns) {
@RequestParam(value = "product_ids") String productIds) {
if (StringUtils.isBlank(skns)) {
return new ApiResponse(500, "skns Is Null", null);
if (StringUtils.isBlank(productIds)) {
return new ApiResponse(400, "productIds Is Null", null);
}
ProductSeriesTemplateResp resp = productService.querySortTemplateData(skns);
ProductSortTemplateResp resp = productService.querySortTemplateData(productIds);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
... ...
package com.yohoufo.product.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class ProductSortTemplate {
@JSONField(name = "image_url")
private String imageUrl;
@JSONField(name = "product_id")
private Integer productId;
@JSONField(name = "product_name")
private String productName;
@JSONField(name = "product_code")
private String productCode;
}
... ...
package com.yohoufo.product.response;
import com.yohoufo.product.model.ProductSortTemplate;
import java.util.List;
public class ProductSortTemplateResp {
private List<ProductSortTemplate> list;
public List<ProductSortTemplate> getList() {
return list;
}
public void setList(List<ProductSortTemplate> list) {
this.list = list;
}
}
... ...
... ... @@ -2,10 +2,7 @@ package com.yohoufo.product.service;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
import com.yohoufo.product.response.*;
public interface ProductService {
... ... @@ -23,7 +20,9 @@ public interface ProductService {
StoragePrice getStoragePriceBySkup(Integer skup);
ProductSeriesTemplateResp querySortTemplateData(String skns);
ProductSeriesTemplateResp querySeriesTemplateData(String skns);
ProductSortTemplateResp querySortTemplateData(String productIds);
}
... ...
... ... @@ -11,9 +11,7 @@ import com.yohoufo.common.utils.UfoStringUtils;
import com.yohoufo.dal.product.*;
import com.yohoufo.dal.product.model.*;
import com.yohoufo.product.model.*;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
import com.yohoufo.product.response.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -22,7 +20,6 @@ import org.springframework.stereotype.Service;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.service.ProductService;
import com.yohoufo.resource.util.DateUtils;
import org.springframework.util.CollectionUtils;
... ... @@ -136,7 +133,34 @@ public class ProductServiceImpl implements ProductService{
}
@Override
public ProductSeriesTemplateResp querySortTemplateData(String skns) {
public ProductSortTemplateResp querySortTemplateData(String productIds) {
ProductSortTemplateResp resp = new ProductSortTemplateResp();
List<ProductSortTemplate> list = new ArrayList<>();
resp.setList(list);
List<Integer> productList = UfoStringUtils.string2IntegerList(productIds);
if (!CollectionUtils.isEmpty(productList)) {
List<Product> products = productMapper.selectByIds(productList);
if (!CollectionUtils.isEmpty(products)) {
List<Goods> goodsList = goodsMapper.selectByProductIds(productList);
Map<Integer, List<Goods>> productGoodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getProductId));
for (Product product : products) {
List<Goods> pgList = productGoodsMap.get(product.getId());
if (!CollectionUtils.isEmpty(pgList) && pgList.get(0) != null && StringUtils.isNotBlank(pgList.get(0).getColorImage())) {
ProductSortTemplate productSortTemplate = new ProductSortTemplate();
productSortTemplate.setProductId(product.getId());
productSortTemplate.setProductName(product.getProductName());
productSortTemplate.setProductCode(product.getProductCode());
productSortTemplate.setImageUrl(pgList.get(0).getColorImage());
list.add(productSortTemplate);
}
}
}
}
return resp;
}
@Override
public ProductSeriesTemplateResp querySeriesTemplateData(String skns) {
ProductSeriesTemplateResp resp = new ProductSeriesTemplateResp();
List<Integer> sknlist = UfoStringUtils.string2IntegerList(skns);
if (!CollectionUtils.isEmpty(sknlist)) {
... ...