Authored by Lixiaodi

尺码多图

@@ -13,5 +13,6 @@ public interface SizePoolMapper { @@ -13,5 +13,6 @@ public interface SizePoolMapper {
13 13
14 SizePool querySizePoolByIds(@Param("sizePoolIds") List<Integer> sizePoolIds); 14 SizePool querySizePoolByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
15 15
  16 + List<SizePool> querySizePoolImagesByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
16 17
17 } 18 }
@@ -32,4 +32,14 @@ @@ -32,4 +32,14 @@
32 limit 1 32 limit 1
33 </select> 33 </select>
34 34
  35 + <select id="querySizePoolImagesByIds" resultMap="BaseResultMap">
  36 + select image_url,image_width,image_height
  37 + from size_pool_image
  38 + where size_pool_id in
  39 + <foreach collection="sizePoolIds" item="sizePoolId" open="(" close=")" separator=",">
  40 + #{sizePoolId}
  41 + </foreach>
  42 + order by size_pool_id
  43 + </select>
  44 +
35 </mapper> 45 </mapper>
@@ -1025,6 +1025,17 @@ public class ProductController { @@ -1025,6 +1025,17 @@ public class ProductController {
1025 return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("getSizeImage success").build(); 1025 return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("getSizeImage success").build();
1026 } 1026 }
1027 1027
  1028 + @ApiOperation(name = "ufo.product.sizeImages", desc = "查询尺码图片(多图)")
  1029 + @RequestMapping(params = "method=ufo.product.sizeImages")
  1030 + @IgnoreSession
  1031 + @Cachable(expire = 300)
  1032 + public ApiResponse sizeImages(@RequestParam(value = "product_id") Integer productId,
  1033 + @RequestParam(value = "brand_id", required = false) Integer brandId) {
  1034 + LOG.info("in method=ufo.product.sizeImages product_id is {}, brandId is {}", productId, brandId);
  1035 + List<SizeImageResp> resultList = productService.getSizeImages(productId, brandId);
  1036 + return new ApiResponse.ApiResponseBuilder().code(200).data(resultList).message("getSizeImages success").build();
  1037 + }
  1038 +
1028 @ApiOperation(name = "ufo.product.vedioImage", desc = "查询视频图片") 1039 @ApiOperation(name = "ufo.product.vedioImage", desc = "查询视频图片")
1029 @RequestMapping(params = "method=ufo.product.vedioImage") 1040 @RequestMapping(params = "method=ufo.product.vedioImage")
1030 @IgnoreSession 1041 @IgnoreSession
@@ -166,5 +166,7 @@ public interface ProductService { @@ -166,5 +166,7 @@ public interface ProductService {
166 166
167 SizeImageResp getSizeImage(Integer productId, Integer brandId); 167 SizeImageResp getSizeImage(Integer productId, Integer brandId);
168 168
  169 + List<SizeImageResp> getSizeImages(Integer productId, Integer brandId);
  170 +
169 VedioImageResp getVedioImage(Integer productId); 171 VedioImageResp getVedioImage(Integer productId);
170 } 172 }
@@ -2013,6 +2013,42 @@ public class ProductServiceImpl implements ProductService { @@ -2013,6 +2013,42 @@ public class ProductServiceImpl implements ProductService {
2013 } 2013 }
2014 2014
2015 @Override 2015 @Override
  2016 + public List<SizeImageResp> getSizeImages(Integer productId, Integer brandId) {
  2017 + List<SizePoolDetail> list = sizePoolDetailMapper.queryByProductId(productId, 1, null);//包括
  2018 + if(CollectionUtils.isEmpty(list)) {
  2019 + if (null == brandId) {
  2020 + Product product = productHelpService.selectByIdCache(productId);
  2021 + brandId = null == product ? null : product.getBrandId();
  2022 + }
  2023 + list = sizePoolDetailMapper.queryByBrandId(brandId);
  2024 + if(!CollectionUtils.isEmpty(list)) {
  2025 + List<SizePoolDetail> notIncludeList = sizePoolDetailMapper.queryByProductId(productId, 0, list.get(0).getSizePoolId());//不包括
  2026 + if(!CollectionUtils.isEmpty(notIncludeList)) {
  2027 + return new ArrayList<>();
  2028 + }
  2029 + }else {
  2030 + return new ArrayList<>();
  2031 + }
  2032 + }
  2033 +
  2034 + List<Integer> poolIdList = list.stream().map(SizePoolDetail::getSizePoolId).collect(Collectors.toList());
  2035 + List<Integer> poolIdListSingle = new ArrayList<>();
  2036 + if (!poolIdList.isEmpty()) {
  2037 + poolIdListSingle.add(poolIdList.get(0));
  2038 + }
  2039 + List<SizePool> poolList = sizePoolMapper.querySizePoolImagesByIds(poolIdListSingle);
  2040 + List<SizeImageResp> respList = new ArrayList<>();
  2041 + for (SizePool sp : poolList) {
  2042 + SizeImageResp re = new SizeImageResp();
  2043 + re.setImageUrl(sp.getImageUrl());
  2044 + re.setImageWidth(sp.getImageWidth());
  2045 + re.setImageHeight(sp.getImageHeight());
  2046 + respList.add(re);
  2047 + }
  2048 + return respList;
  2049 + }
  2050 +
  2051 + @Override
2016 public VedioImageResp getVedioImage(Integer productId) { 2052 public VedioImageResp getVedioImage(Integer productId) {
2017 VedioImageResp resp = new VedioImageResp(); 2053 VedioImageResp resp = new VedioImageResp();
2018 ProductExt ext = productExtMapper.selectByProductId(productId); 2054 ProductExt ext = productExtMapper.selectByProductId(productId);