Authored by Lixiaodi

尺码多图

... ... @@ -12,6 +12,7 @@ import com.yohoufo.dal.product.model.SizePool;
public interface SizePoolMapper {
SizePool querySizePoolByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
List<SizePool> querySizePoolImagesByIds(@Param("sizePoolIds") List<Integer> sizePoolIds);
}
... ...
... ... @@ -31,5 +31,15 @@
</foreach>
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
... ...
... ... @@ -1024,6 +1024,17 @@ public class ProductController {
SizeImageResp result = productService.getSizeImage(productId, brandId);
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")
... ...
... ... @@ -165,6 +165,8 @@ public interface ProductService {
ProductDetailResp queryProductDetail3ById(Integer productId);
SizeImageResp getSizeImage(Integer productId, Integer brandId);
List<SizeImageResp> getSizeImages(Integer productId, Integer brandId);
VedioImageResp getVedioImage(Integer productId);
}
... ...
... ... @@ -2011,6 +2011,42 @@ public class ProductServiceImpl implements ProductService {
return resp;
}
@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) {
... ...