Browse Source

主页画布分类商品数据添加商品收藏信息返回

multiwx
dy-hu 8 months ago
parent
commit
bf03c0ffa6
  1. 10
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java
  2. 11
      cereshop-app/src/main/java/com/shop/cereshop/app/page/canvas/CanvasProduct.java
  3. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java
  4. 13
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java

10
cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java

@ -122,9 +122,15 @@ public class CanvasController {
*/
@GetMapping("getProducts2")
@ApiOperation(value = "商家编辑查询新接口")
public Result<Page<CanvasProduct>> getProducts2(CanvasAppProductParam param) throws CoBusinessException,Exception{
public Result<Page<CanvasProduct>> getProducts2(CanvasAppProductParam param,HttpServletRequest request) throws CoBusinessException,Exception{
String token = request.getHeader("Authorization");
CereBuyerUser user=null;
if(!EmptyUtils.isEmpty(token)){
//根据token查询用户信息
user=cereBuyerUserService.findByToken(token);
}
param.setProject(ContextUtil.getProject());
Page page=cereShopProductService.getProducts2(param);
Page page=cereShopProductService.getProducts2(param,user);
return new Result(page, CoReturnFormat.SUCCESS);
}
/**

11
cereshop-app/src/main/java/com/shop/cereshop/app/page/canvas/CanvasProduct.java

@ -160,6 +160,17 @@ public class CanvasProduct {
@ApiModelProperty(value = "活动倒计时")
private long time;
/**
* 收藏id
*/
@ApiModelProperty(value = "收藏id")
private Long collectId;
/**
* 是否收藏 1- 0-
*/
@ApiModelProperty(value = "是否收藏 1-是 0-否")
private Integer ifCollect=0;
/**
* 名称Map

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java

@ -41,7 +41,7 @@ public interface CereShopProductService {
Page getCanvasProducts(CanvasAppProductParam param) throws CoBusinessException,Exception;
Page getProducts2(CanvasAppProductParam param) throws CoBusinessException,Exception;
Page getProducts2(CanvasAppProductParam param, CereBuyerUser user) throws CoBusinessException,Exception;
List<Classify> getClassify() throws CoBusinessException;

13
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java

@ -974,7 +974,7 @@ public class CereShopProductServiceImpl implements CereShopProductService {
}
@Override
public Page getProducts2(CanvasAppProductParam param) throws CoBusinessException,Exception {
public Page getProducts2(CanvasAppProductParam param, CereBuyerUser user) throws CoBusinessException,Exception {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<CanvasProduct> list=null;
Map<Long,CanvasProductUsers> productUsersMap = new HashMap<>();
@ -1011,13 +1011,13 @@ public class CereShopProductServiceImpl implements CereShopProductService {
productNumberMap = cereShopProductDAO.getProductNumber(param);
}
//填充产品属性
fillProductProperties(list, productUsersMap, productSkuMap, productNumberMap);
fillProductProperties(list, productUsersMap, productSkuMap, productNumberMap, user);
PageInfo<CanvasProduct> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
private void fillProductProperties(List<CanvasProduct> list, Map<Long, CanvasProductUsers> productUsersMap, Map<Long, CanvasProductSku> productSkuMap, Map<Long, CanvasProductNumber> productNumberMap) {
private void fillProductProperties(List<CanvasProduct> list, Map<Long, CanvasProductUsers> productUsersMap, Map<Long, CanvasProductSku> productSkuMap, Map<Long, CanvasProductNumber> productNumberMap, CereBuyerUser user) {
boolean usersMapIsEmpty = productUsersMap.isEmpty();
boolean skuMapIsEmpty = productSkuMap.isEmpty();
@ -1055,6 +1055,13 @@ public class CereShopProductServiceImpl implements CereShopProductService {
product.setStockNumber(productBo.getSurplusNumber());
}
if (ObjectUtils.isNotNull(user)){
CereBuyerCollect collect = cereBuyerCollectService.findByUserProduct(user.getBuyerUserId(),product.getProductId());
if(collect!=null){
product.setCollectId(collect.getCollectId());
product.setIfCollect(collect.getState());
}
}
}
initCanvasProductLangInfo(list);
}

Loading…
Cancel
Save