From bf03c0ffa6546540829de91f15ebd3ef5dabf85f Mon Sep 17 00:00:00 2001 From: dy-hu Date: Tue, 14 May 2024 15:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E7=94=BB=E5=B8=83=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=95=86=E5=93=81=E6=95=B0=E6=8D=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=94=B6=E8=97=8F=E4=BF=A1=E6=81=AF=E8=BF=94?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cereshop/app/controller/canvas/CanvasController.java | 10 ++++++++-- .../com/shop/cereshop/app/page/canvas/CanvasProduct.java | 11 +++++++++++ .../app/service/product/CereShopProductService.java | 2 +- .../service/product/impl/CereShopProductServiceImpl.java | 13 ++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java b/cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java index 04d75c6..f03ae27 100644 --- a/cereshop-app/src/main/java/com/shop/cereshop/app/controller/canvas/CanvasController.java +++ b/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> getProducts2(CanvasAppProductParam param) throws CoBusinessException,Exception{ + public Result> 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); } /** diff --git a/cereshop-app/src/main/java/com/shop/cereshop/app/page/canvas/CanvasProduct.java b/cereshop-app/src/main/java/com/shop/cereshop/app/page/canvas/CanvasProduct.java index 31b3b0a..3be3caf 100644 --- a/cereshop-app/src/main/java/com/shop/cereshop/app/page/canvas/CanvasProduct.java +++ b/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 diff --git a/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java b/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java index 5c7eaaf..365c69e 100644 --- a/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereShopProductService.java +++ b/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 getClassify() throws CoBusinessException; diff --git a/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java b/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java index 02bd5cf..4e581b4 100644 --- a/cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java +++ b/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 list=null; Map 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 pageInfo=new PageInfo<>(list); Page page=new Page(pageInfo.getList(),pageInfo.getTotal()); return page; } - private void fillProductProperties(List list, Map productUsersMap, Map productSkuMap, Map productNumberMap) { + private void fillProductProperties(List list, Map productUsersMap, Map productSkuMap, Map 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); }