Authored by Lixiaodi

尺码多图

... ... @@ -13,5 +13,6 @@ public interface SizePoolMapper {
SizePool querySizePoolByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
List<SizePool> querySizePoolImagesByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
}
... ...
... ... @@ -32,4 +32,14 @@
limit 1
</select>
<select id="querySizePoolImagesByIds" resultMap="BaseResultMap">
select image_url,image_width,image_height
from size_pool_image
where size_pool_id in
<foreach collection="sizePoolIds" item="sizePoolId" open="(" close=")" separator=",">
#{sizePoolId}
</foreach>
order by size_pool_id
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -1025,6 +1025,17 @@ public class ProductController {
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("getSizeImage success").build();
}
@ApiOperation(name = "ufo.product.sizeImages", desc = "查询尺码图片(多图)")
@RequestMapping(params = "method=ufo.product.sizeImages")
@IgnoreSession
@Cachable(expire = 300)
public ApiResponse sizeImages(@RequestParam(value = "product_id") Integer productId,
@RequestParam(value = "brand_id", required = false) Integer brandId) {
LOG.info("in method=ufo.product.sizeImages product_id is {}, brandId is {}", productId, brandId);
List<SizeImageResp> resultList = productService.getSizeImages(productId, brandId);
return new ApiResponse.ApiResponseBuilder().code(200).data(resultList).message("getSizeImages success").build();
}
@ApiOperation(name = "ufo.product.vedioImage", desc = "查询视频图片")
@RequestMapping(params = "method=ufo.product.vedioImage")
@IgnoreSession
... ...
... ... @@ -166,5 +166,7 @@ public interface ProductService {
SizeImageResp getSizeImage(Integer productId, Integer brandId);
List<SizeImageResp> getSizeImages(Integer productId, Integer brandId);
VedioImageResp getVedioImage(Integer productId);
}
... ...
... ... @@ -2013,6 +2013,42 @@ public class ProductServiceImpl implements ProductService {
}
@Override
public List<SizeImageResp> getSizeImages(Integer productId, Integer brandId) {
List<SizePoolDetail> list = sizePoolDetailMapper.queryByProductId(productId, 1, null);//包括
if(CollectionUtils.isEmpty(list)) {
if (null == brandId) {
Product product = productHelpService.selectByIdCache(productId);
brandId = null == product ? null : product.getBrandId();
}
list = sizePoolDetailMapper.queryByBrandId(brandId);
if(!CollectionUtils.isEmpty(list)) {
List<SizePoolDetail> notIncludeList = sizePoolDetailMapper.queryByProductId(productId, 0, list.get(0).getSizePoolId());//不包括
if(!CollectionUtils.isEmpty(notIncludeList)) {
return new ArrayList<>();
}
}else {
return new ArrayList<>();
}
}
List<Integer> poolIdList = list.stream().map(SizePoolDetail::getSizePoolId).collect(Collectors.toList());
List<Integer> poolIdListSingle = new ArrayList<>();
if (!poolIdList.isEmpty()) {
poolIdListSingle.add(poolIdList.get(0));
}
List<SizePool> poolList = sizePoolMapper.querySizePoolImagesByIds(poolIdListSingle);
List<SizeImageResp> respList = new ArrayList<>();
for (SizePool sp : poolList) {
SizeImageResp re = new SizeImageResp();
re.setImageUrl(sp.getImageUrl());
re.setImageWidth(sp.getImageWidth());
re.setImageHeight(sp.getImageHeight());
respList.add(re);
}
return respList;
}
@Override
public VedioImageResp getVedioImage(Integer productId) {
VedioImageResp resp = new VedioImageResp();
ProductExt ext = productExtMapper.selectByProductId(productId);
... ...