|
|
@ -8,6 +8,9 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package co.yixiang.modules.hotList.service.impl; |
|
|
|
package co.yixiang.modules.hotList.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
|
|
import co.yixiang.exception.ErrorRequestException; |
|
|
|
|
|
|
|
import co.yixiang.modules.product.service.mapper.StoreProductMapper; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import co.yixiang.common.service.impl.BaseServiceImpl; |
|
|
|
import co.yixiang.common.service.impl.BaseServiceImpl; |
|
|
@ -54,16 +57,13 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap |
|
|
|
private final IGenerator generator; |
|
|
|
private final IGenerator generator; |
|
|
|
private final YxStoreProductService yxStoreProductService; |
|
|
|
private final YxStoreProductService yxStoreProductService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final StoreProductMapper storeProductMapper; |
|
|
|
@SneakyThrows |
|
|
|
@SneakyThrows |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
//@Cacheable
|
|
|
|
//@Cacheable
|
|
|
|
public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) { |
|
|
|
public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) { |
|
|
|
getPage(pageable); |
|
|
|
getPage(pageable); |
|
|
|
PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria)); |
|
|
|
PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria)); |
|
|
|
// PageInfo<YxStoreHotListVo> page1 = new PageInfo<>();
|
|
|
|
|
|
|
|
// BeanUtils.copyProperties(page,page1);
|
|
|
|
|
|
|
|
// BeanUtilsBean.getInstance().copyProperties(page1, page);
|
|
|
|
|
|
|
|
page.getList().forEach(hotList->{ |
|
|
|
page.getList().forEach(hotList->{ |
|
|
|
List<Integer> productArr = JSONUtil.toList(hotList.getProductList(), Integer.class); |
|
|
|
List<Integer> productArr = JSONUtil.toList(hotList.getProductList(), Integer.class); |
|
|
|
List<YxStoreProduct> list1 =new ArrayList<>(); |
|
|
|
List<YxStoreProduct> list1 =new ArrayList<>(); |
|
|
@ -72,8 +72,11 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap |
|
|
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
.eq(YxStoreProduct::getId, productId); |
|
|
|
.eq(YxStoreProduct::getId, productId); |
|
|
|
//这里需要有一个非空判断
|
|
|
|
//这里需要有一个非空判断
|
|
|
|
YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(productId)); |
|
|
|
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper); |
|
|
|
list1.add(yxStoreProduct); |
|
|
|
// YxStoreProduct storeProduct=storeProductMapper.selectById(productId);
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(storeProduct)){ |
|
|
|
|
|
|
|
list1.add(storeProduct); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
hotList.setProductList(JSONUtil.toJsonStr(list1)); |
|
|
|
hotList.setProductList(JSONUtil.toJsonStr(list1)); |
|
|
|
// hotList.setProductInfo(list1);
|
|
|
|
// hotList.setProductInfo(list1);
|
|
|
@ -117,9 +120,14 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap |
|
|
|
List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); |
|
|
|
List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); |
|
|
|
List<YxStoreProduct> list1 =new ArrayList<>(); |
|
|
|
List<YxStoreProduct> list1 =new ArrayList<>(); |
|
|
|
productArr.forEach(productId->{ |
|
|
|
productArr.forEach(productId->{ |
|
|
|
//这里需要有一个非空判断
|
|
|
|
LambdaQueryWrapper<YxStoreProduct> wrapper1 = new LambdaQueryWrapper<>(); |
|
|
|
YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(productId)); |
|
|
|
wrapper1.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
list1.add(yxStoreProduct); |
|
|
|
.eq(YxStoreProduct::getId, productId); |
|
|
|
|
|
|
|
YxStoreProduct yxStoreProduct = storeProductMapper.selectOne(wrapper1); |
|
|
|
|
|
|
|
//这里需要有一个非空判断,找不到这个商品就不加
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(yxStoreProduct)){ |
|
|
|
|
|
|
|
list1.add(yxStoreProduct); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
hotListDto.setProductInfo(list1); |
|
|
|
hotListDto.setProductInfo(list1); |
|
|
|
}); |
|
|
|
}); |
|
|
|