From 341404eafa6e7aef7cc7fec997d1799a71454ce1 Mon Sep 17 00:00:00 2001 From: zhuyang <1qazxsw2> Date: Sat, 9 Oct 2021 22:56:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManagementWebApplication.java | 3 +- .../activity/PromotionActivityManager.java | 11 ++-- .../promotion/brand/BannerManager.java | 16 +++--- .../coupon/CouponTemplateManager.java | 16 +++--- .../recommend/ProductRecommendManager.java | 15 +++-- .../promotion-service-api/pom.xml | 4 ++ .../rpc/activity/PromotionActivityFeign.java | 28 +++++++++ .../rpc/activity/PromotionActivityRpc.java | 20 ------- .../promotion/api/rpc/banner/BannerFeign.java | 35 ++++++++++++ .../promotion/api/rpc/banner/BannerRpc.java | 52 ----------------- .../api/rpc/coupon/CouponCardFeign.java | 35 ++++++++++++ .../api/rpc/coupon/CouponCardRpc.java | 54 ------------------ .../api/rpc/coupon/CouponTemplateFeign.java | 39 +++++++++++++ .../api/rpc/coupon/CouponTemplateRpc.java | 57 ------------------- .../promotion/api/rpc/price/PriceFeign.java | 21 +++++++ .../promotion/api/rpc/price/PriceRpc.java | 14 ----- .../rpc/recommend/ProductRecommendFeign.java | 38 +++++++++++++ .../rpc/recommend/ProductRecommendRpc.java | 52 ----------------- .../controller/BannerController.java | 57 +++++++++++++++++++ .../controller/CouponCardController.java | 55 ++++++++++++++++++ .../CouponTemplateController.java} | 38 +++++++------ .../PriceController.java} | 25 +++++--- .../ProductRecommendController.java} | 39 +++++++------ .../PromotionActivityController.java} | 31 ++++++---- .../rpc/banner/BannerRpcImpl.java | 48 ---------------- .../rpc/coupon/CouponCardRpcImpl.java | 46 --------------- .../mall/shopweb/ShopWebApplication.java | 2 +- .../service/product/ProductSkuManager.java | 18 +++--- .../service/promotion/BannerManager.java | 12 ++-- .../service/promotion/CouponCardManager.java | 13 ++--- .../promotion/CouponTemplateManager.java | 12 ++-- .../promotion/ProductRecommendManager.java | 10 ++-- .../shopweb/service/trade/CartManager.java | 18 +++--- .../service/trade/TradeOrderService.java | 25 ++++---- .../tradeservice/TradeServiceApplication.java | 2 +- .../client/promotion/CouponCardClient.java | 11 ++-- .../client/promotion/PriceClient.java | 11 ++-- 37 files changed, 486 insertions(+), 497 deletions(-) create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityRpc.java create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerRpc.java create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardRpc.java create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateRpc.java create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceRpc.java create mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendFeign.java delete mode 100644 promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendRpc.java create mode 100644 promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/BannerController.java create mode 100644 promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponCardController.java rename promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/{rpc/coupon/CouponTemplateRpcImpl.java => controller/CouponTemplateController.java} (53%) rename promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/{rpc/price/PriceRpcImpl.java => controller/PriceController.java} (51%) rename promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/{rpc/recommend/ProductRecommendRpcImpl.java => controller/ProductRecommendController.java} (52%) rename promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/{rpc/activity/PromotionActivityRpcImpl.java => controller/PromotionActivityController.java} (57%) delete mode 100644 promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/banner/BannerRpcImpl.java delete mode 100644 promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponCardRpcImpl.java diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java index 65879a3d..c6442411 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java @@ -7,7 +7,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"}) +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc" +,"cn.iocoder.mall.promotion.api.rpc"}) public class ManagementWebApplication { public static void main(String[] args) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/activity/PromotionActivityManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/activity/PromotionActivityManager.java index 91b09045..2c4f8aac 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/activity/PromotionActivityManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/activity/PromotionActivityManager.java @@ -4,9 +4,9 @@ import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO; import cn.iocoder.mall.managementweb.convert.promotion.PromotionActivityConvert; -import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; +import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -17,11 +17,12 @@ import org.springframework.validation.annotation.Validated; @Validated public class PromotionActivityManager { - @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") - private PromotionActivityRpc promotionActivityRpc; + + @Autowired + private PromotionActivityFeign promotionActivityFeign; public PageResult pagePromotionActivity(PromotionActivityPageReqVO pageReqVO) { - CommonResult> pagePromotionActivityResult = promotionActivityRpc.pagePromotionActivity( + CommonResult> pagePromotionActivityResult = promotionActivityFeign.pagePromotionActivity( PromotionActivityConvert.INSTANCE.convert(pageReqVO)); pagePromotionActivityResult.checkError(); return pagePromotionActivityResult.getData(); diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/brand/BannerManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/brand/BannerManager.java index 17ed69da..8b621f64 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/brand/BannerManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/brand/BannerManager.java @@ -7,9 +7,9 @@ import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReq import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO; import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO; import cn.iocoder.mall.managementweb.convert.promotion.BannerConvert; -import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc; +import cn.iocoder.mall.promotion.api.rpc.banner.BannerFeign; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -18,8 +18,8 @@ import org.springframework.stereotype.Service; @Service public class BannerManager { - @DubboReference(version = "${dubbo.consumer.BannerRpc.version}") - private BannerRpc bannerRpc; + @Autowired + private BannerFeign bannerFeign; /** * 创建 Banner @@ -28,7 +28,7 @@ public class BannerManager { * @return Banner */ public Integer createBanner(BannerCreateReqVO createVO) { - CommonResult createBannerResult = bannerRpc.createBanner(BannerConvert.INSTANCE.convert(createVO)); + CommonResult createBannerResult = bannerFeign.createBanner(BannerConvert.INSTANCE.convert(createVO)); createBannerResult.checkError(); return createBannerResult.getData(); } @@ -39,7 +39,7 @@ public class BannerManager { * @param updateVO 更新 Banner VO */ public void updateBanner(BannerUpdateReqVO updateVO) { - CommonResult updateBannerResult = bannerRpc.updateBanner(BannerConvert.INSTANCE.convert(updateVO)); + CommonResult updateBannerResult = bannerFeign.updateBanner(BannerConvert.INSTANCE.convert(updateVO)); updateBannerResult.checkError(); } @@ -49,7 +49,7 @@ public class BannerManager { * @param bannerId Banner 编号 */ public void deleteBanner(Integer bannerId) { - CommonResult deleteBannerResult = bannerRpc.deleteBanner(bannerId); + CommonResult deleteBannerResult = bannerFeign.deleteBanner(bannerId); deleteBannerResult.checkError(); } @@ -60,7 +60,7 @@ public class BannerManager { * @return Banner 分页结果 */ public PageResult pageBanner(BannerPageReqVO pageVO) { - CommonResult> pageBannerResult = bannerRpc.pageBanner(BannerConvert.INSTANCE.convert(pageVO)); + CommonResult> pageBannerResult = bannerFeign.pageBanner(BannerConvert.INSTANCE.convert(pageVO)); pageBannerResult.checkError(); return BannerConvert.INSTANCE.convertPage(pageBannerResult.getData()); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/coupon/CouponTemplateManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/coupon/CouponTemplateManager.java index bedc7c4b..29a42ee4 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/coupon/CouponTemplateManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/coupon/CouponTemplateManager.java @@ -7,10 +7,10 @@ import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.Cou import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO; import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO; import cn.iocoder.mall.managementweb.convert.promotion.CouponTemplateConvert; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc; +import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateFeign; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -18,20 +18,20 @@ import org.springframework.validation.annotation.Validated; @Validated public class CouponTemplateManager { - @DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}") - private CouponTemplateRpc couponTemplateRpc; + @Autowired + private CouponTemplateFeign couponTemplateFeign; // ========== 通用逻辑 ========= public PageResult pageCouponTemplate(CouponTemplatePageReqVO pageVO) { CommonResult> pageCouponTemplateResult = - couponTemplateRpc.pageCouponTemplate(CouponTemplateConvert.INSTANCE.convert(pageVO)); + couponTemplateFeign.pageCouponTemplate(CouponTemplateConvert.INSTANCE.convert(pageVO)); pageCouponTemplateResult.checkError(); return CouponTemplateConvert.INSTANCE.convertPage(pageCouponTemplateResult.getData()); } public void updateCouponTemplateStatus(Integer id, Integer status) { - CommonResult updateCouponTemplateStatusResult = couponTemplateRpc.updateCouponTemplateStatus( + CommonResult updateCouponTemplateStatusResult = couponTemplateFeign.updateCouponTemplateStatus( new CouponCardTemplateUpdateStatusReqDTO().setId(id).setStatus(status)); updateCouponTemplateStatusResult.checkError(); } @@ -39,14 +39,14 @@ public class CouponTemplateManager { // ========== 优惠劵模板 ========== public Integer createCouponCardTemplate(CouponTemplateCardCreateReqVO createVO) { - CommonResult createCouponCardTemplateResult = couponTemplateRpc.createCouponCardTemplate( + CommonResult createCouponCardTemplateResult = couponTemplateFeign.createCouponCardTemplate( CouponTemplateConvert.INSTANCE.convert(createVO)); createCouponCardTemplateResult.checkError(); return createCouponCardTemplateResult.getData(); } public void updateCouponCardTemplate(CouponTemplateCardUpdateReqVO updateVO) { - CommonResult updateCouponCardTemplateResult = couponTemplateRpc.updateCouponCardTemplate( + CommonResult updateCouponCardTemplateResult = couponTemplateFeign.updateCouponCardTemplate( CouponTemplateConvert.INSTANCE.convert(updateVO)); updateCouponCardTemplateResult.checkError(); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/recommend/ProductRecommendManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/recommend/ProductRecommendManager.java index 6bd4b7a9..8921e29d 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/recommend/ProductRecommendManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/recommend/ProductRecommendManager.java @@ -10,9 +10,8 @@ import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRe import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO; -import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc; +import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendFeign; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -27,8 +26,8 @@ import java.util.Map; @Validated public class ProductRecommendManager { - @DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}") - private ProductRecommendRpc productRecommendRpc; + @Autowired + private ProductRecommendFeign productRecommendFeign; @Autowired private ProductSpuFeign productSpuFeign; /** @@ -38,7 +37,7 @@ public class ProductRecommendManager { * @return 商品推荐 */ public Integer createProductRecommend(ProductRecommendCreateReqVO createVO) { - CommonResult createProductRecommendResult = productRecommendRpc.createProductRecommend( + CommonResult createProductRecommendResult = productRecommendFeign.createProductRecommend( ProductRecommendConvert.INSTANCE.convert(createVO)); createProductRecommendResult.checkError(); return createProductRecommendResult.getData(); @@ -50,7 +49,7 @@ public class ProductRecommendManager { * @param updateVO 更新商品推荐 VO */ public void updateProductRecommend(ProductRecommendUpdateReqVO updateVO) { - CommonResult updateProductRecommendResult = productRecommendRpc.updateProductRecommend( + CommonResult updateProductRecommendResult = productRecommendFeign.updateProductRecommend( ProductRecommendConvert.INSTANCE.convert(updateVO)); updateProductRecommendResult.checkError(); } @@ -61,7 +60,7 @@ public class ProductRecommendManager { * @param productRecommendId 商品推荐编号 */ public void deleteProductRecommend(Integer productRecommendId) { - CommonResult deleteProductRecommendResult = productRecommendRpc.deleteProductRecommend(productRecommendId); + CommonResult deleteProductRecommendResult = productRecommendFeign.deleteProductRecommend(productRecommendId); deleteProductRecommendResult.checkError(); } @@ -72,7 +71,7 @@ public class ProductRecommendManager { * @return 商品推荐分页结果 */ public PageResult pageProductRecommend(ProductRecommendPageReqVO pageVO) { - CommonResult> pageProductRecommendResult = productRecommendRpc.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO)); + CommonResult> pageProductRecommendResult = productRecommendFeign.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO)); pageProductRecommendResult.checkError(); // 拼接结果 PageResult pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData()); diff --git a/promotion-service-project/promotion-service-api/pom.xml b/promotion-service-project/promotion-service-api/pom.xml index a5a77335..ccc6b137 100644 --- a/promotion-service-project/promotion-service-api/pom.xml +++ b/promotion-service-project/promotion-service-api/pom.xml @@ -44,6 +44,10 @@ hibernate-validator true + + org.springframework.cloud + spring-cloud-openfeign-core + diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java new file mode 100644 index 00000000..f7b197b5 --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java @@ -0,0 +1,28 @@ +package cn.iocoder.mall.promotion.api.rpc.activity; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; +import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; +import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface PromotionActivityFeign { + + @PostMapping("/promotion/activity/pagePromotionActivity") + CommonResult> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) ; + @PostMapping("/promotion/activity/listPromotionActivities") + CommonResult> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) ; +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityRpc.java deleted file mode 100644 index cca8e08a..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityRpc.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.activity; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; - -import java.util.List; - -/** - * 促销活动 Rpc 接口 - */ -public interface PromotionActivityRpc { - - CommonResult> pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO); - - CommonResult> listPromotionActivities(PromotionActivityListReqDTO listReqDTO); - -} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerFeign.java new file mode 100644 index 00000000..cd8344e0 --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerFeign.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.promotion.api.rpc.banner; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.banner.dto.*; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface BannerFeign { + + @PostMapping("/promotion/banner/createBanner") + public CommonResult createBanner(@RequestBody BannerCreateReqDTO createDTO) ; + @PostMapping("/promotion/banner/updateBanner") + public CommonResult updateBanner(@RequestBody BannerUpdateReqDTO updateDTO) ; + + @PostMapping("/promotion/banner/deleteBanner") + public CommonResult deleteBanner(@RequestBody Integer bannerId) ; + + @PostMapping("/promotion/banner/listBanners") + public CommonResult> listBanners(@RequestBody BannerListReqDTO listDTO) ; + + @PostMapping("/promotion/banner/pageBanner") + public CommonResult> pageBanner(@RequestBody BannerPageReqDTO pageDTO); +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerRpc.java deleted file mode 100644 index 9d3efab6..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/banner/BannerRpc.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.banner; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.banner.dto.*; - -import java.util.List; - -/** - * Banner Rpc 接口 - */ -public interface BannerRpc { - - /** - * 创建 Banner - * - * @param createDTO 创建 Banner DTO - * @return Banner 编号 - */ - CommonResult createBanner(BannerCreateReqDTO createDTO); - - /** - * 更新 Banner - * - * @param updateDTO 更新 Banner DTO - */ - CommonResult updateBanner(BannerUpdateReqDTO updateDTO); - - /** - * 删除 Banner - * - * @param bannerId Banner 编号 - */ - CommonResult deleteBanner(Integer bannerId); - - /** - * 获得 Banner 列表 - * - * @param listDTO Banner 列表查询 DTO - * @return Banner 列表 - */ - CommonResult> listBanners(BannerListReqDTO listDTO); - - /** - * 获得 Banner 分页 - * - * @param pageDTO Banner 分页查询 - * @return Banner 分页结果 - */ - CommonResult> pageBanner(BannerPageReqDTO pageDTO); - -} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java new file mode 100644 index 00000000..7ff4a14f --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.promotion.api.rpc.coupon; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface CouponCardFeign { + @PostMapping("/coupon/card/pageCouponCard") + public CommonResult> pageCouponCard(@RequestBody CouponCardPageReqDTO pageReqDTO) ; + + @PostMapping("/coupon/card/createCouponCard") + public CommonResult createCouponCard(@RequestBody CouponCardCreateReqDTO createReqDTO); + + @PostMapping("/coupon/card/useCouponCard") + public CommonResult useCouponCard(@RequestBody CouponCardUseReqDTO useReqDTO) ; + + @PostMapping("/coupon/card/cancelUseCouponCard") + public CommonResult cancelUseCouponCard(@RequestBody CouponCardCancelUseReqDTO cancelUseReqDTO) ; + + @PostMapping("/coupon/card/listAvailableCouponCards") + public CommonResult> listAvailableCouponCards(@RequestBody CouponCardAvailableListReqDTO listReqDTO); +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardRpc.java deleted file mode 100644 index 555fb55e..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardRpc.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*; - -import java.util.List; - -/** - * 优惠劵 Rpc 接口 - */ -public interface CouponCardRpc { - - /** - * 获得优惠劵分页 - * - * @param pageReqDTO 优惠劵分页查询 - * @return 优惠劵分页结果 - */ - CommonResult> pageCouponCard(CouponCardPageReqDTO pageReqDTO); - - /** - * 给用户添加优惠劵 - * - * @param createReqDTO 创建信息 - * @return 优惠劵编号 - */ - CommonResult createCouponCard(CouponCardCreateReqDTO createReqDTO); - - /** - * 用户使用优惠劵 - * - * @param useReqDTO 使用信息 - * @return 成功 - */ - CommonResult useCouponCard(CouponCardUseReqDTO useReqDTO); - - /** - * 用户取消使用优惠劵 - * - * @param cancelUseReqDTO 取消使用信息 - * @return 成功 - */ - CommonResult cancelUseCouponCard(CouponCardCancelUseReqDTO cancelUseReqDTO); - - /** - * 获得用户优惠劵的可用信息列表 - * - * @param listReqDTO 查询信息 - * @return 优惠劵的可用信息列表 - */ - CommonResult> listAvailableCouponCards(CouponCardAvailableListReqDTO listReqDTO); - -} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateFeign.java new file mode 100644 index 00000000..50a4955a --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateFeign.java @@ -0,0 +1,39 @@ +package cn.iocoder.mall.promotion.api.rpc.coupon; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface CouponTemplateFeign { + // ========== 通用逻辑 ========= + + @GetMapping("/coupon/template/getCouponTemplate") + public CommonResult getCouponTemplate(@RequestParam("couponTemplateId") Integer couponTemplateId); + + @PostMapping("/coupon/template/pageCouponTemplate") + public CommonResult> pageCouponTemplate(@RequestBody CouponTemplatePageReqDTO pageDTO); + + @PostMapping("/coupon/template/updateCouponTemplateStatus") + public CommonResult updateCouponTemplateStatus(@RequestBody CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) ; + + // ========== 优惠劵模板 ========== + + @PostMapping("/coupon/template/createCouponCardTemplate") + public CommonResult createCouponCardTemplate(@RequestBody CouponCardTemplateCreateReqDTO createDTO) ; + + @PostMapping("/coupon/template/updateCouponCardTemplate") + public CommonResult updateCouponCardTemplate(@RequestBody CouponCardTemplateUpdateReqDTO updateDTO) ; +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateRpc.java deleted file mode 100644 index 53ac4a3b..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponTemplateRpc.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*; - -/** - * 优惠劵模板 Rpc 接口 - */ -public interface CouponTemplateRpc { - - // ========== 通用逻辑 ========= - - /** - * 获得优惠劵(码)模板 - * - * @param couponTemplateId 优惠劵模板编号 - * @return 优惠劵模板 - */ - CommonResult getCouponTemplate(Integer couponTemplateId); - - /** - * 获得优惠劵(码)模板分页 - * - * @param pageDTO 优惠劵模板分页查询 - * @return 优惠劵模板分页结果 - */ - CommonResult> pageCouponTemplate(CouponTemplatePageReqDTO pageDTO); - - /** - * 更新优惠劵(码)模板的状态 - * - * @param updateStatusReqDTO 更新状态 DTO - */ - CommonResult updateCouponTemplateStatus(CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO); - - // ========== 优惠劵模板 ========== - - /** - * 创建优惠劵模板 - * - * @param createDTO 创建优惠劵模板 DTO - * @return 优惠劵模板编号 - */ - CommonResult createCouponCardTemplate(CouponCardTemplateCreateReqDTO createDTO); - - /** - * 更新优惠劵模板 - * - * @param updateDTO 更新优惠劵模板 DTO - */ - CommonResult updateCouponCardTemplate(CouponCardTemplateUpdateReqDTO updateDTO); - - // ========== 优惠码模板 ========== - - -} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceFeign.java new file mode 100644 index 00000000..e87f7f16 --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceFeign.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.promotion.api.rpc.price; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; +import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface PriceFeign { + @PostMapping("/promotion/price/calcProductPrice") + public CommonResult calcProductPrice(@RequestBody PriceProductCalcReqDTO calcReqDTO) ; +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceRpc.java deleted file mode 100644 index 991def4b..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/price/PriceRpc.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.price; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; -import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; - -/** - * 价格 Rpc 接口,提供价格计算的功能 - */ -public interface PriceRpc { - - CommonResult calcProductPrice(PriceProductCalcReqDTO calcReqDTO); - -} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendFeign.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendFeign.java new file mode 100644 index 00000000..8925fcff --- /dev/null +++ b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendFeign.java @@ -0,0 +1,38 @@ +package cn.iocoder.mall.promotion.api.rpc.recommend; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient("promotion-service") +public interface ProductRecommendFeign { + + @PostMapping("/promotion/prod/recommend/createProductRecommend") + public CommonResult createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) ; + + @PostMapping("/promotion/prod/recommend/updateProductRecommend") + public CommonResult updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO); + + @GetMapping("/promotion/prod/recommend/deleteProductRecommend") + public CommonResult deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) ; + + @PostMapping("/promotion/prod/recommend/listProductRecommends") + public CommonResult> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) ; + + @PostMapping("/promotion/prod/recommend/pageProductRecommend") + public CommonResult> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) ; +} diff --git a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendRpc.java b/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendRpc.java deleted file mode 100644 index 7afbbe4d..00000000 --- a/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/recommend/ProductRecommendRpc.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.recommend; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*; - -import java.util.List; - -/** - * 商品推荐 Rpc 接口 - */ -public interface ProductRecommendRpc { - - /** - * 创建商品推荐 - * - * @param createDTO 创建商品推荐 DTO - * @return 商品推荐编号 - */ - CommonResult createProductRecommend(ProductRecommendCreateReqDTO createDTO); - - /** - * 更新商品推荐 - * - * @param updateDTO 更新商品推荐 DTO - */ - CommonResult updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO); - - /** - * 删除商品推荐 - * - * @param productRecommendId 商品推荐编号 - */ - CommonResult deleteProductRecommend(Integer productRecommendId); - - /** - * 获得商品推荐列表 - * - * @param listReqDTO 商品推荐列表查询 DTO - * @return 商品推荐列表 - */ - CommonResult> listProductRecommends(ProductRecommendListReqDTO listReqDTO); - - /** - * 获得商品推荐分页 - * - * @param pageDTO 商品推荐分页查询 - * @return 商品推荐分页结果 - */ - CommonResult> pageProductRecommend(ProductRecommendPageReqDTO pageDTO); - -} diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/BannerController.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/BannerController.java new file mode 100644 index 00000000..e4b473b2 --- /dev/null +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/BannerController.java @@ -0,0 +1,57 @@ +package cn.iocoder.mall.promotionservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.banner.dto.*; +import cn.iocoder.mall.promotionservice.manager.banner.BannerManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/promotion/banner") +public class BannerController { + + @Autowired + private BannerManager bannerManager; + + @PostMapping("createBanner") + public CommonResult createBanner(@RequestBody BannerCreateReqDTO createDTO) { + return success(bannerManager.createBanner(createDTO)); + } + + @PostMapping("updateBanner") + public CommonResult updateBanner(@RequestBody BannerUpdateReqDTO updateDTO) { + bannerManager.updateBanner(updateDTO); + return success(true); + } + + @PostMapping("deleteBanner") + public CommonResult deleteBanner(@RequestBody Integer bannerId) { + bannerManager.deleteBanner(bannerId); + return success(true); + } + + @PostMapping("listBanners") + public CommonResult> listBanners(@RequestBody BannerListReqDTO listDTO) { + return success(bannerManager.listBanners(listDTO)); + } + + @PostMapping("pageBanner") + public CommonResult> pageBanner(@RequestBody BannerPageReqDTO pageDTO) { + return success(bannerManager.pageBanner(pageDTO)); + } +} diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponCardController.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponCardController.java new file mode 100644 index 00000000..fa9d0d95 --- /dev/null +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponCardController.java @@ -0,0 +1,55 @@ +package cn.iocoder.mall.promotionservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*; +import cn.iocoder.mall.promotionservice.manager.coupon.CouponCardManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/coupon/card") +public class CouponCardController { + + @Autowired + private CouponCardManager couponCardManager; + + @PostMapping("pageCouponCard") + public CommonResult> pageCouponCard(@RequestBody CouponCardPageReqDTO pageReqDTO) { + return success(couponCardManager.pageCouponCard(pageReqDTO)); + } + + @PostMapping("createCouponCard") + public CommonResult createCouponCard(@RequestBody CouponCardCreateReqDTO createReqDTO) { + return success(couponCardManager.createCouponCard(createReqDTO)); + } + + @PostMapping("useCouponCard") + public CommonResult useCouponCard(@RequestBody CouponCardUseReqDTO useReqDTO) { + return success(couponCardManager.useCouponCard(useReqDTO)); + } + + @PostMapping("cancelUseCouponCard") + public CommonResult cancelUseCouponCard(@RequestBody CouponCardCancelUseReqDTO cancelUseReqDTO) { + return success(couponCardManager.cancelUseCouponCard(cancelUseReqDTO)); + } + + @PostMapping("listAvailableCouponCards") + public CommonResult> listAvailableCouponCards(@RequestBody CouponCardAvailableListReqDTO listReqDTO) { + return success(couponCardManager.listAvailableCouponCards(listReqDTO)); + } +} diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponTemplateRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java similarity index 53% rename from promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponTemplateRpcImpl.java rename to promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java index f43d5f2c..01e46b76 100644 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponTemplateRpcImpl.java +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java @@ -1,50 +1,56 @@ -package cn.iocoder.mall.promotionservice.rpc.coupon; +package cn.iocoder.mall.promotionservice.controller; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*; import cn.iocoder.mall.promotionservice.manager.coupon.CouponTemplateManager; -import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; import static cn.iocoder.common.framework.vo.CommonResult.success; -@DubboService -public class CouponTemplateRpcImpl implements CouponTemplateRpc { +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/coupon/template") +public class CouponTemplateController { @Autowired private CouponTemplateManager couponTemplateManager; // ========== 通用逻辑 ========= - @Override - public CommonResult getCouponTemplate(Integer couponTemplateId) { + @GetMapping("getCouponTemplate") + public CommonResult getCouponTemplate(@RequestParam("couponTemplateId") Integer couponTemplateId) { return success(couponTemplateManager.getCouponTemplate(couponTemplateId)); } - @Override - public CommonResult> pageCouponTemplate(CouponTemplatePageReqDTO pageDTO) { + @PostMapping("pageCouponTemplate") + public CommonResult> pageCouponTemplate(@RequestBody CouponTemplatePageReqDTO pageDTO) { return success(couponTemplateManager.pageCouponTemplate(pageDTO)); } - @Override - public CommonResult updateCouponTemplateStatus(CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) { + @PostMapping("updateCouponTemplateStatus") + public CommonResult updateCouponTemplateStatus(@RequestBody CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) { couponTemplateManager.updateCouponTemplateStatus(updateStatusReqDTO); return success(true); } // ========== 优惠劵模板 ========== - @Override - public CommonResult createCouponCardTemplate(CouponCardTemplateCreateReqDTO createDTO) { + @PostMapping("createCouponCardTemplate") + public CommonResult createCouponCardTemplate(@RequestBody CouponCardTemplateCreateReqDTO createDTO) { return success(couponTemplateManager.createCouponCardTemplate(createDTO)); } - @Override - public CommonResult updateCouponCardTemplate(CouponCardTemplateUpdateReqDTO updateDTO) { + @PostMapping("updateCouponCardTemplate") + public CommonResult updateCouponCardTemplate(@RequestBody CouponCardTemplateUpdateReqDTO updateDTO) { couponTemplateManager.updateCouponCardTemplate(updateDTO); return success(true); } - } diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/price/PriceRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java similarity index 51% rename from promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/price/PriceRpcImpl.java rename to promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java index 096d84b6..bfa59667 100644 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/price/PriceRpcImpl.java +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java @@ -1,24 +1,33 @@ -package cn.iocoder.mall.promotionservice.rpc.price; +package cn.iocoder.mall.promotionservice.controller; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotionservice.manager.price.PriceManager; -import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import static cn.iocoder.common.framework.vo.CommonResult.success; -@DubboService -public class PriceRpcImpl implements PriceRpc { +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/promotion/price") +public class PriceController { @Autowired private PriceManager priceManager; - @Override - public CommonResult calcProductPrice(PriceProductCalcReqDTO calcReqDTO) { + @PostMapping("calcProductPrice") + public CommonResult calcProductPrice(@RequestBody PriceProductCalcReqDTO calcReqDTO) { return success(priceManager.calcProductPrice(calcReqDTO)); } - } diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/recommend/ProductRecommendRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/ProductRecommendController.java similarity index 52% rename from promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/recommend/ProductRecommendRpcImpl.java rename to promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/ProductRecommendController.java index 140f20b3..497a14ad 100644 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/recommend/ProductRecommendRpcImpl.java +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/ProductRecommendController.java @@ -1,48 +1,55 @@ -package cn.iocoder.mall.promotionservice.rpc.recommend; +package cn.iocoder.mall.promotionservice.controller; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*; import cn.iocoder.mall.promotionservice.manager.recommend.ProductRecommendManager; -import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; -@DubboService -public class ProductRecommendRpcImpl implements ProductRecommendRpc { +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/promotion/prod/recommend") +public class ProductRecommendController { @Autowired private ProductRecommendManager productRecommendManager; - @Override - public CommonResult createProductRecommend(ProductRecommendCreateReqDTO createDTO) { + + @PostMapping("createProductRecommend") + public CommonResult createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) { return success(productRecommendManager.createProductRecommend(createDTO)); } - @Override - public CommonResult updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO) { + @PostMapping("updateProductRecommend") + public CommonResult updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO) { productRecommendManager.updateProductRecommend(updateDTO); return success(true); } - @Override - public CommonResult deleteProductRecommend(Integer productRecommendId) { + @GetMapping("deleteProductRecommend") + public CommonResult deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) { productRecommendManager.deleteProductRecommend(productRecommendId); return success(true); } - @Override - public CommonResult> listProductRecommends(ProductRecommendListReqDTO listReqDTO) { + @PostMapping("listProductRecommends") + public CommonResult> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) { return success(productRecommendManager.listProductRecommends(listReqDTO)); } - @Override - public CommonResult> pageProductRecommend(ProductRecommendPageReqDTO pageDTO) { + @PostMapping("pageProductRecommend") + public CommonResult> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) { return success(productRecommendManager.pageProductRecommend(pageDTO)); } - } diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/activity/PromotionActivityRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PromotionActivityController.java similarity index 57% rename from promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/activity/PromotionActivityRpcImpl.java rename to promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PromotionActivityController.java index 7b05a0a4..8e33ad5f 100644 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/activity/PromotionActivityRpcImpl.java +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PromotionActivityController.java @@ -1,33 +1,40 @@ -package cn.iocoder.mall.promotionservice.rpc.activity; +package cn.iocoder.mall.promotionservice.controller; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotionservice.manager.activity.PromotionActivityManager; -import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; -@DubboService -public class PromotionActivityRpcImpl implements PromotionActivityRpc { - +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/promotion/activity") +public class PromotionActivityController { @Autowired private PromotionActivityManager promotionActivityManager; - @Override - public CommonResult> pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO) { + @PostMapping("pagePromotionActivity") + public CommonResult> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) { return success(promotionActivityManager.pagePromotionActivity(pageReqDTO)); } - - @Override - public CommonResult> listPromotionActivities(PromotionActivityListReqDTO listReqDTO) { + @PostMapping("listPromotionActivities") + public CommonResult> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) { return success(promotionActivityManager.listPromotionActivities(listReqDTO)); } - } diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/banner/BannerRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/banner/BannerRpcImpl.java deleted file mode 100644 index 50523e60..00000000 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/banner/BannerRpcImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.mall.promotionservice.rpc.banner; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc; -import cn.iocoder.mall.promotion.api.rpc.banner.dto.*; -import cn.iocoder.mall.promotionservice.manager.banner.BannerManager; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -@DubboService -public class BannerRpcImpl implements BannerRpc { - - @Autowired - private BannerManager bannerManager; - - @Override - public CommonResult createBanner(BannerCreateReqDTO createDTO) { - return success(bannerManager.createBanner(createDTO)); - } - - @Override - public CommonResult updateBanner(BannerUpdateReqDTO updateDTO) { - bannerManager.updateBanner(updateDTO); - return success(true); - } - - @Override - public CommonResult deleteBanner(Integer bannerId) { - bannerManager.deleteBanner(bannerId); - return success(true); - } - - @Override - public CommonResult> listBanners(BannerListReqDTO listDTO) { - return success(bannerManager.listBanners(listDTO)); - } - - @Override - public CommonResult> pageBanner(BannerPageReqDTO pageDTO) { - return success(bannerManager.pageBanner(pageDTO)); - } - -} diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponCardRpcImpl.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponCardRpcImpl.java deleted file mode 100644 index aa1dc30b..00000000 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/rpc/coupon/CouponCardRpcImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.mall.promotionservice.rpc.coupon; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*; -import cn.iocoder.mall.promotionservice.manager.coupon.CouponCardManager; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -@DubboService -public class CouponCardRpcImpl implements CouponCardRpc { - - @Autowired - private CouponCardManager couponCardManager; - - @Override - public CommonResult> pageCouponCard(CouponCardPageReqDTO pageReqDTO) { - return success(couponCardManager.pageCouponCard(pageReqDTO)); - } - - @Override - public CommonResult createCouponCard(CouponCardCreateReqDTO createReqDTO) { - return success(couponCardManager.createCouponCard(createReqDTO)); - } - - @Override - public CommonResult useCouponCard(CouponCardUseReqDTO useReqDTO) { - return success(couponCardManager.useCouponCard(useReqDTO)); - } - - @Override - public CommonResult cancelUseCouponCard(CouponCardCancelUseReqDTO cancelUseReqDTO) { - return success(couponCardManager.cancelUseCouponCard(cancelUseReqDTO)); - } - - @Override - public CommonResult> listAvailableCouponCards(CouponCardAvailableListReqDTO listReqDTO) { - return success(couponCardManager.listAvailableCouponCards(listReqDTO)); - } - -} diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java index 944a3326..a6b488a0 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java @@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc", - "cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc"}) + "cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc","cn.iocoder.mall.promotion.api.rpc"}) public class ShopWebApplication { public static void main(String[] args) { diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSkuManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSkuManager.java index dc2f272d..1acb589a 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSkuManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSkuManager.java @@ -1,15 +1,15 @@ package cn.iocoder.mall.shopweb.service.product; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; +import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; -import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; +import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.shopweb.controller.product.vo.sku.ProductSkuCalcPriceRespVO; import cn.iocoder.mall.shopweb.convert.product.ProductSkuConvert; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -23,11 +23,11 @@ import java.util.List; @Validated public class ProductSkuManager { - @DubboReference(version = "${dubbo.consumer.PriceRpc.version}") - private PriceRpc priceRpc; - @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") - private PromotionActivityRpc promotionActivityRpc; + @Autowired + private PriceFeign priceFeign; + @Autowired + private PromotionActivityFeign promotionActivityFeign; /** * 计算商品 SKU 价格 * @@ -36,7 +36,7 @@ public class ProductSkuManager { * @return SKU 价格明细 */ public ProductSkuCalcPriceRespVO calcProductSkuPrice(Integer userId, Integer skuId) { - CommonResult calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) + CommonResult calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) .setItems(Collections.singletonList(new PriceProductCalcReqDTO.Item(skuId, 1, true)))); calcProductPriceResult.checkError(); // 拼接结果 @@ -51,7 +51,7 @@ public class ProductSkuManager { } private PromotionActivityRespDTO getPromotionActivity(Integer activityId) { - CommonResult> listPromotionActivitiesResult = promotionActivityRpc.listPromotionActivities( + CommonResult> listPromotionActivitiesResult = promotionActivityFeign.listPromotionActivities( new PromotionActivityListReqDTO().setActiveIds(Collections.singleton(activityId))); listPromotionActivitiesResult.checkError(); return listPromotionActivitiesResult.getData().get(0); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/BannerManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/BannerManager.java index 9eac17e6..ba2f90b0 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/BannerManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/BannerManager.java @@ -2,12 +2,12 @@ package cn.iocoder.mall.shopweb.service.promotion; import cn.iocoder.common.framework.enums.CommonStatusEnum; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc; +import cn.iocoder.mall.promotion.api.rpc.banner.BannerFeign; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerListReqDTO; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO; import cn.iocoder.mall.shopweb.controller.promotion.vo.brand.BannerRespVO; import cn.iocoder.mall.shopweb.convert.promotion.BannerConvert; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -20,13 +20,11 @@ import java.util.List; @Service @Validated public class BannerManager { - - @DubboReference(version = "${dubbo.consumer.BannerRpc.version}") - private BannerRpc bannerRpc; - + @Autowired + private BannerFeign bannerFeign; public List listBanners() { // 获取 Banner 列表 - CommonResult> listBannersResult = bannerRpc.listBanners( + CommonResult> listBannersResult = bannerFeign.listBanners( new BannerListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue())); listBannersResult.checkError(); // 排序返回 diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponCardManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponCardManager.java index 06552ed3..c5abb432 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponCardManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponCardManager.java @@ -2,13 +2,13 @@ package cn.iocoder.mall.shopweb.service.promotion; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; +import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardCreateReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardRespDTO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardPageReqVO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardRespVO; import cn.iocoder.mall.shopweb.convert.promotion.CouponCardConvert; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -17,9 +17,8 @@ import org.springframework.stereotype.Service; @Service public class CouponCardManager { - @DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") - private CouponCardRpc couponCardRpc; - + @Autowired + private CouponCardFeign couponCardFeign; /** * 获得优惠劵分页 * @@ -28,7 +27,7 @@ public class CouponCardManager { * @return 优惠劵分页结果 */ public PageResult pageCouponCard(Integer userId, CouponCardPageReqVO pageVO) { - CommonResult> pageCouponCardResult = couponCardRpc.pageCouponCard( + CommonResult> pageCouponCardResult = couponCardFeign.pageCouponCard( CouponCardConvert.INSTANCE.convert(pageVO).setUserId(userId)); pageCouponCardResult.checkError(); return CouponCardConvert.INSTANCE.convertPage(pageCouponCardResult.getData()); @@ -42,7 +41,7 @@ public class CouponCardManager { * @return 优惠劵编号 */ public Integer createCouponCard(Integer userId, Integer couponTemplateId) { - CommonResult createCouponCardResult = couponCardRpc.createCouponCard( + CommonResult createCouponCardResult = couponCardFeign.createCouponCard( new CouponCardCreateReqDTO().setUserId(userId).setCouponTemplateId(couponTemplateId)); createCouponCardResult.checkError(); return createCouponCardResult.getData(); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponTemplateManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponTemplateManager.java index ca40dd76..7fbffc65 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponTemplateManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/CouponTemplateManager.java @@ -1,11 +1,11 @@ package cn.iocoder.mall.shopweb.service.promotion; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc; +import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateFeign; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO; import cn.iocoder.mall.shopweb.convert.promotion.CouponTemplateConvert; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -13,12 +13,10 @@ import org.springframework.stereotype.Service; */ @Service public class CouponTemplateManager { - - @DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}") - private CouponTemplateRpc couponTemplateRpc; - + @Autowired + private CouponTemplateFeign couponTemplateFeign; public CouponTemplateRespVO getCouponTemplate(Integer id) { - CommonResult getCouponTemplateResult = couponTemplateRpc.getCouponTemplate(id); + CommonResult getCouponTemplateResult = couponTemplateFeign.getCouponTemplate(id); getCouponTemplateResult.checkError(); return CouponTemplateConvert.INSTANCE.convert(getCouponTemplateResult.getData()); } diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/ProductRecommendManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/ProductRecommendManager.java index 43d62a8d..e0faa835 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/ProductRecommendManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/ProductRecommendManager.java @@ -5,14 +5,13 @@ import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO; -import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc; +import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendFeign; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO; import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO; import cn.iocoder.mall.shopweb.convert.promotion.ProductRecommendConvert; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -28,15 +27,14 @@ import java.util.Map; @Service @Validated public class ProductRecommendManager { - - @DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}") - private ProductRecommendRpc productRecommendRpc; + @Autowired + private ProductRecommendFeign productRecommendFeign; @Autowired private ProductSpuFeign productSpuFeign; public Map> listProductRecommends() { // 查询商品推荐列表 - CommonResult> listProductRecommendsResult = productRecommendRpc.listProductRecommends( + CommonResult> listProductRecommendsResult = productRecommendFeign.listProductRecommends( new ProductRecommendListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue())); listProductRecommendsResult.checkError(); listProductRecommendsResult.getData().sort(Comparator.comparing(ProductRecommendRespDTO::getSort)); // 排序,按照 sort 升序 diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java index b220106f..e29777ff 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java @@ -6,17 +6,16 @@ import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; +import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; -import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; +import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.shopweb.controller.trade.vo.cart.CartDetailVO; import cn.iocoder.mall.shopweb.convert.trade.CartConvert; import cn.iocoder.mall.tradeservice.rpc.cart.CartFeign; import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -31,10 +30,11 @@ public class CartManager { @Autowired private CartFeign cartFeign; - @DubboReference(version = "${dubbo.consumer.PriceRpc.version}") - private PriceRpc priceRpc; - @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") - private PromotionActivityRpc promotionActivityRpc; + @Autowired + private PriceFeign priceFeign; + + @Autowired + private PromotionActivityFeign promotionActivityFeign; @Autowired private ProductSkuFeign productSkuFeign; @@ -107,7 +107,7 @@ public class CartManager { return result; } // 计算商品价格 - CommonResult calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) + CommonResult calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) .setItems(listCartItemsResult.getData().stream() .map(cartItem -> new PriceProductCalcReqDTO.Item(cartItem.getSkuId(), cartItem.getQuantity(), cartItem.getSelected())) .collect(Collectors.toList()))); @@ -154,7 +154,7 @@ public class CartManager { } // 查询促销活动列表 CommonResult> listPromotionActivitiesResult = - promotionActivityRpc.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); + promotionActivityFeign.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); listPromotionActivitiesResult.checkError(); return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId); } diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java index de4105e9..a804c81a 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java @@ -9,13 +9,13 @@ import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; +import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; +import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableListReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableRespDTO; -import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; +import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.shopweb.client.trade.TradeOrderClient; @@ -31,7 +31,6 @@ import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemListReqDTO; import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemRespDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -49,15 +48,15 @@ import static cn.iocoder.mall.shopweb.enums.ShopWebErrorCodeConstants.ORDER_PROD @Validated public class TradeOrderService { - @DubboReference(version = "${dubbo.consumer.PriceRpc.version}") - private PriceRpc priceRpc; - @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") - private PromotionActivityRpc promotionActivityRpc; + @Autowired + private PriceFeign priceFeign; + @Autowired + private PromotionActivityFeign promotionActivityFeign; @Autowired private CartFeign cartFeign; - private CouponCardRpc couponCardRpc; - + @Autowired + private CouponCardFeign couponCardFeign; @Autowired private ProductSkuFeign productSkuFeign; @@ -94,7 +93,7 @@ public class TradeOrderService { // 获得商品 SKU 信息 Map productSkuMap = this.checkProductSkus(skuMap); // 计算商品价格 - CommonResult calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO() + CommonResult calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO() .setUserId(userId).setCouponCardId(couponCardId) .setItems(skuMap.entrySet().stream().map(entry -> new PriceProductCalcReqDTO.Item(entry.getKey(), entry.getValue(), true)) .collect(Collectors.toList()))); @@ -119,7 +118,7 @@ public class TradeOrderService { productSkuMap.get(item.getSkuId()), promotionActivityMap.get(item.getActivityId())))); } // 查询可用优惠劵信息 - CommonResult> listAvailableCouponCardsResult = couponCardRpc.listAvailableCouponCards( + CommonResult> listAvailableCouponCardsResult = couponCardFeign.listAvailableCouponCards( new CouponCardAvailableListReqDTO().setUserId(userId) .setItems(TradeOrderConvert.INSTANCE.convertList(calcProductPriceResult.getData().getItemGroups()))); listAvailableCouponCardsResult.checkError(); @@ -165,7 +164,7 @@ public class TradeOrderService { } // 查询促销活动列表 CommonResult> listPromotionActivitiesResult = - promotionActivityRpc.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); + promotionActivityFeign.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); listPromotionActivitiesResult.checkError(); return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId); } diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java index c1fcbdbf..57c0977a 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java @@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"}) +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.promotion.api.rpc"}) public class TradeServiceApplication { public static void main(String[] args) { diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/CouponCardClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/CouponCardClient.java index cf6b3dcb..63b56f42 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/CouponCardClient.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/CouponCardClient.java @@ -1,19 +1,18 @@ package cn.iocoder.mall.tradeservice.client.promotion; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; +import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardUseReqDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class CouponCardClient { - @DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") - private CouponCardRpc couponCardRpc; - + @Autowired + private CouponCardFeign couponCardFeign; public void useCouponCard(Integer userId, Integer couponCardId) { - CommonResult useCouponCardResult = couponCardRpc.useCouponCard(new CouponCardUseReqDTO() + CommonResult useCouponCardResult = couponCardFeign.useCouponCard(new CouponCardUseReqDTO() .setUserId(userId).setCouponCardId(couponCardId)); useCouponCardResult.checkError(); } diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/PriceClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/PriceClient.java index 5e354c0d..226de425 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/PriceClient.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/promotion/PriceClient.java @@ -1,10 +1,10 @@ package cn.iocoder.mall.tradeservice.client.promotion; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; +import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -12,9 +12,8 @@ import java.util.List; @Service public class PriceClient { - @DubboReference(version = "${dubbo.consumer.PriceRpc.version}") - private PriceRpc priceRpc; - + @Autowired + private PriceFeign priceFeign; /** * 计算商品们的价格 * @@ -25,7 +24,7 @@ public class PriceClient { */ public PriceProductCalcRespDTO calcProductPrice(Integer userId, List items, Integer couponCardId) { - CommonResult calcProductPriceResult = priceRpc.calcProductPrice( + CommonResult calcProductPriceResult = priceFeign.calcProductPrice( new PriceProductCalcReqDTO().setUserId(userId).setItems(items).setCouponCardId(couponCardId)); calcProductPriceResult.checkError(); return calcProductPriceResult.getData();