add productsorttemplate
Showing
6 changed files
with
91 additions
and
21 deletions
@@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
78 | from product | 78 | from product |
79 | </select> | 79 | </select> |
80 | <select id="selectByIds" resultMap="BaseResultMap"> | 80 | <select id="selectByIds" resultMap="BaseResultMap"> |
81 | - select id, series_id from product where id in | 81 | + select id, product_name, product_code, series_id from product where id in |
82 | <foreach item="item" index="index" collection="list" | 82 | <foreach item="item" index="index" collection="list" |
83 | open="(" separator="," close=")"> | 83 | open="(" separator="," close=")"> |
84 | #{item} | 84 | #{item} |
@@ -3,6 +3,7 @@ package com.yohoufo.product.controller; | @@ -3,6 +3,7 @@ package com.yohoufo.product.controller; | ||
3 | import java.util.concurrent.ExecutorService; | 3 | import java.util.concurrent.ExecutorService; |
4 | import java.util.concurrent.Executors; | 4 | import java.util.concurrent.Executors; |
5 | 5 | ||
6 | +import com.yohoufo.product.response.*; | ||
6 | import org.apache.commons.lang3.StringUtils; | 7 | import org.apache.commons.lang3.StringUtils; |
7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
@@ -22,10 +23,6 @@ import com.yohoufo.common.caller.UfoServiceCaller; | @@ -22,10 +23,6 @@ import com.yohoufo.common.caller.UfoServiceCaller; | ||
22 | import com.yohoufo.common.utils.UfoJsonUtil; | 23 | import com.yohoufo.common.utils.UfoJsonUtil; |
23 | import com.yohoufo.dal.product.model.StoragePrice; | 24 | import com.yohoufo.dal.product.model.StoragePrice; |
24 | import com.yohoufo.product.request.StoragePriceBo; | 25 | import com.yohoufo.product.request.StoragePriceBo; |
25 | -import com.yohoufo.product.response.ProductDetailResp; | ||
26 | -import com.yohoufo.product.response.ProductSeriesTemplateResp; | ||
27 | -import com.yohoufo.product.response.StorageDataResp; | ||
28 | -import com.yohoufo.product.response.StorageLeastPriceResp; | ||
29 | import com.yohoufo.product.service.ProductService; | 26 | import com.yohoufo.product.service.ProductService; |
30 | 27 | ||
31 | 28 | ||
@@ -46,7 +43,7 @@ public class ProductController { | @@ -46,7 +43,7 @@ public class ProductController { | ||
46 | @RequestMapping(params = "method=ufo.product.data") | 43 | @RequestMapping(params = "method=ufo.product.data") |
47 | @Cachable(expire=600) | 44 | @Cachable(expire=600) |
48 | public ApiResponse queryProductDetailById( | 45 | public ApiResponse queryProductDetailById( |
49 | - @RequestParam(value = "product_id", required = true) Integer productId) { | 46 | + @RequestParam(value = "product_id") Integer productId) { |
50 | 47 | ||
51 | if (null == productId) { | 48 | if (null == productId) { |
52 | return new ApiResponse(400, "product_id Is Null", null); | 49 | return new ApiResponse(400, "product_id Is Null", null); |
@@ -57,19 +54,33 @@ public class ProductController { | @@ -57,19 +54,33 @@ public class ProductController { | ||
57 | return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); | 54 | return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); |
58 | } | 55 | } |
59 | 56 | ||
57 | + @ApiOperation(name = "ufo.product.series.template", desc="商品系列列表") | ||
58 | + @IgnoreSignature | ||
59 | + @IgnoreSession | ||
60 | + @RequestMapping(params = "method=ufo.product.series.template") | ||
61 | + //@Cachable(expire=600) | ||
62 | + public ApiResponse querySeriesTemplateData( | ||
63 | + @RequestParam(value = "product_ids") String productIds) { | ||
64 | + | ||
65 | + if (StringUtils.isBlank(productIds)) { | ||
66 | + return new ApiResponse(400, "productIds Is Null", null); | ||
67 | + } | ||
68 | + ProductSeriesTemplateResp resp = productService.querySeriesTemplateData(productIds); | ||
69 | + return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); | ||
70 | + } | ||
71 | + | ||
60 | @ApiOperation(name = "ufo.product.sort.template", desc="商品列表") | 72 | @ApiOperation(name = "ufo.product.sort.template", desc="商品列表") |
61 | @IgnoreSignature | 73 | @IgnoreSignature |
62 | @IgnoreSession | 74 | @IgnoreSession |
63 | @RequestMapping(params = "method=ufo.product.sort.template") | 75 | @RequestMapping(params = "method=ufo.product.sort.template") |
64 | //@Cachable(expire=600) | 76 | //@Cachable(expire=600) |
65 | public ApiResponse querySortTemplateData( | 77 | public ApiResponse querySortTemplateData( |
66 | - @RequestParam(value = "skns", required = false) String skns) { | 78 | + @RequestParam(value = "product_ids") String productIds) { |
67 | 79 | ||
68 | - if (StringUtils.isBlank(skns)) { | ||
69 | - return new ApiResponse(500, "skns Is Null", null); | 80 | + if (StringUtils.isBlank(productIds)) { |
81 | + return new ApiResponse(400, "productIds Is Null", null); | ||
70 | } | 82 | } |
71 | - | ||
72 | - ProductSeriesTemplateResp resp = productService.querySortTemplateData(skns); | 83 | + ProductSortTemplateResp resp = productService.querySortTemplateData(productIds); |
73 | return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); | 84 | return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); |
74 | } | 85 | } |
75 | 86 |
1 | +package com.yohoufo.product.model; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.annotation.JSONField; | ||
4 | +import lombok.Data; | ||
5 | + | ||
6 | +@Data | ||
7 | +public class ProductSortTemplate { | ||
8 | + | ||
9 | + @JSONField(name = "image_url") | ||
10 | + private String imageUrl; | ||
11 | + @JSONField(name = "product_id") | ||
12 | + private Integer productId; | ||
13 | + @JSONField(name = "product_name") | ||
14 | + private String productName; | ||
15 | + @JSONField(name = "product_code") | ||
16 | + private String productCode; | ||
17 | +} |
1 | +package com.yohoufo.product.response; | ||
2 | + | ||
3 | +import com.yohoufo.product.model.ProductSortTemplate; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public class ProductSortTemplateResp { | ||
8 | + | ||
9 | + private List<ProductSortTemplate> list; | ||
10 | + | ||
11 | + | ||
12 | + public List<ProductSortTemplate> getList() { | ||
13 | + return list; | ||
14 | + } | ||
15 | + | ||
16 | + public void setList(List<ProductSortTemplate> list) { | ||
17 | + this.list = list; | ||
18 | + } | ||
19 | +} |
@@ -2,10 +2,7 @@ package com.yohoufo.product.service; | @@ -2,10 +2,7 @@ package com.yohoufo.product.service; | ||
2 | 2 | ||
3 | import com.yohoufo.dal.product.model.StoragePrice; | 3 | import com.yohoufo.dal.product.model.StoragePrice; |
4 | import com.yohoufo.product.request.StoragePriceBo; | 4 | import com.yohoufo.product.request.StoragePriceBo; |
5 | -import com.yohoufo.product.response.ProductDetailResp; | ||
6 | -import com.yohoufo.product.response.ProductSeriesTemplateResp; | ||
7 | -import com.yohoufo.product.response.StorageDataResp; | ||
8 | -import com.yohoufo.product.response.StorageLeastPriceResp; | 5 | +import com.yohoufo.product.response.*; |
9 | 6 | ||
10 | public interface ProductService { | 7 | public interface ProductService { |
11 | 8 | ||
@@ -23,7 +20,9 @@ public interface ProductService { | @@ -23,7 +20,9 @@ public interface ProductService { | ||
23 | 20 | ||
24 | StoragePrice getStoragePriceBySkup(Integer skup); | 21 | StoragePrice getStoragePriceBySkup(Integer skup); |
25 | 22 | ||
26 | - ProductSeriesTemplateResp querySortTemplateData(String skns); | 23 | + ProductSeriesTemplateResp querySeriesTemplateData(String skns); |
24 | + | ||
25 | + ProductSortTemplateResp querySortTemplateData(String productIds); | ||
27 | 26 | ||
28 | 27 | ||
29 | } | 28 | } |
@@ -11,9 +11,7 @@ import com.yohoufo.common.utils.UfoStringUtils; | @@ -11,9 +11,7 @@ import com.yohoufo.common.utils.UfoStringUtils; | ||
11 | import com.yohoufo.dal.product.*; | 11 | import com.yohoufo.dal.product.*; |
12 | import com.yohoufo.dal.product.model.*; | 12 | import com.yohoufo.dal.product.model.*; |
13 | import com.yohoufo.product.model.*; | 13 | import com.yohoufo.product.model.*; |
14 | -import com.yohoufo.product.response.ProductSeriesTemplateResp; | ||
15 | -import com.yohoufo.product.response.StorageDataResp; | ||
16 | -import com.yohoufo.product.response.StorageLeastPriceResp; | 14 | +import com.yohoufo.product.response.*; |
17 | import org.apache.commons.lang3.StringUtils; | 15 | import org.apache.commons.lang3.StringUtils; |
18 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
19 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
@@ -22,7 +20,6 @@ import org.springframework.stereotype.Service; | @@ -22,7 +20,6 @@ import org.springframework.stereotype.Service; | ||
22 | 20 | ||
23 | import com.yoho.error.exception.ServiceException; | 21 | import com.yoho.error.exception.ServiceException; |
24 | import com.yohoufo.product.request.StoragePriceBo; | 22 | import com.yohoufo.product.request.StoragePriceBo; |
25 | -import com.yohoufo.product.response.ProductDetailResp; | ||
26 | import com.yohoufo.product.service.ProductService; | 23 | import com.yohoufo.product.service.ProductService; |
27 | import com.yohoufo.resource.util.DateUtils; | 24 | import com.yohoufo.resource.util.DateUtils; |
28 | import org.springframework.util.CollectionUtils; | 25 | import org.springframework.util.CollectionUtils; |
@@ -136,7 +133,34 @@ public class ProductServiceImpl implements ProductService{ | @@ -136,7 +133,34 @@ public class ProductServiceImpl implements ProductService{ | ||
136 | } | 133 | } |
137 | 134 | ||
138 | @Override | 135 | @Override |
139 | - public ProductSeriesTemplateResp querySortTemplateData(String skns) { | 136 | + public ProductSortTemplateResp querySortTemplateData(String productIds) { |
137 | + ProductSortTemplateResp resp = new ProductSortTemplateResp(); | ||
138 | + List<ProductSortTemplate> list = new ArrayList<>(); | ||
139 | + resp.setList(list); | ||
140 | + List<Integer> productList = UfoStringUtils.string2IntegerList(productIds); | ||
141 | + if (!CollectionUtils.isEmpty(productList)) { | ||
142 | + List<Product> products = productMapper.selectByIds(productList); | ||
143 | + if (!CollectionUtils.isEmpty(products)) { | ||
144 | + List<Goods> goodsList = goodsMapper.selectByProductIds(productList); | ||
145 | + Map<Integer, List<Goods>> productGoodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getProductId)); | ||
146 | + for (Product product : products) { | ||
147 | + List<Goods> pgList = productGoodsMap.get(product.getId()); | ||
148 | + if (!CollectionUtils.isEmpty(pgList) && pgList.get(0) != null && StringUtils.isNotBlank(pgList.get(0).getColorImage())) { | ||
149 | + ProductSortTemplate productSortTemplate = new ProductSortTemplate(); | ||
150 | + productSortTemplate.setProductId(product.getId()); | ||
151 | + productSortTemplate.setProductName(product.getProductName()); | ||
152 | + productSortTemplate.setProductCode(product.getProductCode()); | ||
153 | + productSortTemplate.setImageUrl(pgList.get(0).getColorImage()); | ||
154 | + list.add(productSortTemplate); | ||
155 | + } | ||
156 | + } | ||
157 | + } | ||
158 | + } | ||
159 | + return resp; | ||
160 | + } | ||
161 | + | ||
162 | + @Override | ||
163 | + public ProductSeriesTemplateResp querySeriesTemplateData(String skns) { | ||
140 | ProductSeriesTemplateResp resp = new ProductSeriesTemplateResp(); | 164 | ProductSeriesTemplateResp resp = new ProductSeriesTemplateResp(); |
141 | List<Integer> sknlist = UfoStringUtils.string2IntegerList(skns); | 165 | List<Integer> sknlist = UfoStringUtils.string2IntegerList(skns); |
142 | if (!CollectionUtils.isEmpty(sknlist)) { | 166 | if (!CollectionUtils.isEmpty(sknlist)) { |
-
Please register or login to post a comment