From 50d8aac20f762ef2d7b038243a8fd4098edb3201 Mon Sep 17 00:00:00 2001 From: zhuyang <1qazxsw2> Date: Thu, 7 Oct 2021 23:45:17 +0800 Subject: [PATCH] =?UTF-8?q?ProductCategory=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/ProductCategoryController.http | 14 ++- .../product/ProductCategoryManager.java | 18 +-- .../rpc/brand/ProductBrandRpc.java | 63 ----------- .../rpc/category/ProductCategoryFeign.java | 68 +++++++++++ .../rpc/category/ProductCategoryRpc.java | 62 ---------- .../controller/ProductCategoryController.java | 107 ++++++++++++++++++ .../rpc/brand/ProductBrandRpcImpl.java | 58 ---------- .../rpc/category/ProductCategoryRpcImpl.java | 58 ---------- .../manager/product/SearchProductManager.java | 8 +- .../product/ProductCategoryManager.java | 11 +- .../service/product/ProductSpuManager.java | 8 +- 11 files changed, 209 insertions(+), 266 deletions(-) delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpc.java create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryFeign.java delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpc.java create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductCategoryController.java delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpcImpl.java delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpcImpl.java diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.http index 7badf2772..e6acf7396 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductCategoryController.http @@ -1,7 +1,15 @@ ### /product-category/tree 成功 -GET {{baseUrl}}/product-category/tree +GET http://127.0.0.1:18083/management-api/product-category/tree Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{accessToken}} -dubbo-tag: {{dubboTag}} +Authorization: Bearer yudaoyuanma ### + +POST http://127.0.0.1:18083/management-api/product-category/create +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer yudaoyuanma + +pid=0&name=美食&description=吃喝拉撒&sort=7&status=1 + + +### \ No newline at end of file diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductCategoryManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductCategoryManager.java index 59ffbb490..b6a43eeda 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductCategoryManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductCategoryManager.java @@ -6,11 +6,11 @@ import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCateg import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCategoryUpdateReqVO; import cn.iocoder.mall.managementweb.convert.product.ProductCategoryConvert; import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum; -import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc; +import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import lombok.extern.slf4j.Slf4j; -import org.apache.dubbo.config.annotation.Reference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @@ -22,10 +22,10 @@ import java.util.stream.Collectors; @Service @Slf4j public class ProductCategoryManager { + - @Reference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private ProductCategoryRpc productCategoryRpc; - + @Autowired + private ProductCategoryFeign productCategoryFeign; /** * 创建商品分类表 * @@ -33,7 +33,7 @@ public class ProductCategoryManager { * @return 商品分类表 */ public Integer createProductCategory(ProductCategoryCreateReqVO createVO) { - CommonResult createProductCategoryResult = productCategoryRpc.createProductCategory(ProductCategoryConvert.INSTANCE.convert(createVO)); + CommonResult createProductCategoryResult = productCategoryFeign.createProductCategory(ProductCategoryConvert.INSTANCE.convert(createVO)); createProductCategoryResult.checkError(); return createProductCategoryResult.getData(); } @@ -44,7 +44,7 @@ public class ProductCategoryManager { * @param updateVO 更新商品分类表 VO */ public void updateProductCategory(ProductCategoryUpdateReqVO updateVO) { - CommonResult updateProductCategoryResult = productCategoryRpc.updateProductCategory(ProductCategoryConvert.INSTANCE.convert(updateVO)); + CommonResult updateProductCategoryResult = productCategoryFeign.updateProductCategory(ProductCategoryConvert.INSTANCE.convert(updateVO)); updateProductCategoryResult.checkError(); } @@ -54,7 +54,7 @@ public class ProductCategoryManager { * @param productCategoryId 商品分类表编号 */ public void deleteProductCategory(Integer productCategoryId) { - CommonResult deleteProductCategoryResult = productCategoryRpc.deleteProductCategory(productCategoryId); + CommonResult deleteProductCategoryResult = productCategoryFeign.deleteProductCategory(productCategoryId); deleteProductCategoryResult.checkError(); } @@ -65,7 +65,7 @@ public class ProductCategoryManager { */ public List treeProductCategory() { // 获得商品分类全列表 - CommonResult> listProductCategories = productCategoryRpc.listProductCategories(new ProductCategoryListQueryReqDTO()); + CommonResult> listProductCategories = productCategoryFeign.listProductCategories(new ProductCategoryListQueryReqDTO()); listProductCategories.checkError(); // 构建菜单树 return buildProductCategoryTree(listProductCategories.getData()); diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpc.java deleted file mode 100644 index 3e62a022b..000000000 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpc.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.brand; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO; - -import java.util.List; - -/** -* 商品品牌 Rpc 接口 -*/ -public interface ProductBrandRpc { - - /** - * 创建商品品牌 - * - * @param createDTO 创建商品品牌 DTO - * @return 商品品牌编号 - */ - CommonResult createProductBrand(ProductBrandCreateReqDTO createDTO); - - /** - * 更新商品品牌 - * - * @param updateDTO 更新商品品牌 DTO - */ - CommonResult updateProductBrand(ProductBrandUpdateReqDTO updateDTO); - - /** - * 删除商品品牌 - * - * @param productBrandId 商品品牌编号 - */ - CommonResult deleteProductBrand(Integer productBrandId); - - /** - * 获得商品品牌 - * - * @param productBrandId 商品品牌编号 - * @return 商品品牌 - */ - CommonResult getProductBrand(Integer productBrandId); - - /** - * 获得商品品牌列表 - * - * @param productBrandIds 商品品牌编号列表 - * @return 商品品牌列表 - */ - CommonResult> listProductBrands(List productBrandIds); - - /** - * 获得商品品牌分页 - * - * @param pageDTO 商品品牌分页查询 - * @return 商品品牌分页结果 - */ - CommonResult> pageProductBrand(ProductBrandPageReqDTO pageDTO); - -} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryFeign.java new file mode 100644 index 000000000..6a21efc11 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryFeign.java @@ -0,0 +1,68 @@ +package cn.iocoder.mall.productservice.rpc.category; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO; +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.Collection; +import java.util.List; + +@FeignClient(value = "product-service") +public interface ProductCategoryFeign { + + /** + * 创建商品分类 + * + * @param createDTO 创建商品分类 DTO + * @return 商品分类编号 + */ + @PostMapping("/product/category/createProductCategory") + CommonResult createProductCategory(@RequestBody ProductCategoryCreateReqDTO createDTO); + /** + * 更新商品分类 + * + * @param updateDTO 更新商品分类 DTO + */ + @PostMapping("/product/category/updateProductCategory") + CommonResult updateProductCategory(@RequestBody ProductCategoryUpdateReqDTO updateDTO); + + /** + * 删除商品分类 + * + * @param productCategoryId 商品分类编号 + */ + @GetMapping("/product/category/deleteProductCategory") + CommonResult deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId); + /** + * 获得商品分类 + * + * @param productCategoryId 商品分类编号 + * @return 商品分类 + */ + @GetMapping("/product/category/getProductCategory") + CommonResult getProductCategory(@RequestParam("productCategoryId")Integer productCategoryId); + /** + * 获得商品分类列表 + * + * @param productCategoryIds 商品分类编号列表 + * @return 商品分类列表 + */ + @GetMapping("/product/category/listProductCategoriesByIds") + CommonResult> listProductCategoriesByIds(@RequestParam("productCategoryIds")Collection productCategoryIds); + + /** + * 获得符合条件的商品分类列表 + * + * @return 商品分类列表 + */ + @PostMapping("/product/category/listProductCategories") + CommonResult> listProductCategories(@RequestBody ProductCategoryListQueryReqDTO listQueryReqDTO); + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpc.java deleted file mode 100644 index d18725fe7..000000000 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpc.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.category; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO; - -import java.util.Collection; -import java.util.List; - -/** -* 商品分类 Rpc 接口 -*/ -public interface ProductCategoryRpc { - - /** - * 创建商品分类 - * - * @param createDTO 创建商品分类 DTO - * @return 商品分类编号 - */ - CommonResult createProductCategory(ProductCategoryCreateReqDTO createDTO); - - /** - * 更新商品分类 - * - * @param updateDTO 更新商品分类 DTO - */ - CommonResult updateProductCategory(ProductCategoryUpdateReqDTO updateDTO); - - /** - * 删除商品分类 - * - * @param productCategoryId 商品分类编号 - */ - CommonResult deleteProductCategory(Integer productCategoryId); - - /** - * 获得商品分类 - * - * @param productCategoryId 商品分类编号 - * @return 商品分类 - */ - CommonResult getProductCategory(Integer productCategoryId); - - /** - * 获得商品分类列表 - * - * @param productCategoryIds 商品分类编号列表 - * @return 商品分类列表 - */ - CommonResult> listProductCategories(Collection productCategoryIds); - - /** - * 获得符合条件的商品分类列表 - * - * @return 商品分类列表 - */ - CommonResult> listProductCategories(ProductCategoryListQueryReqDTO listQueryReqDTO); - -} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductCategoryController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductCategoryController.java new file mode 100644 index 000000000..5e36faebf --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductCategoryController.java @@ -0,0 +1,107 @@ +package cn.iocoder.mall.productservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager; +import cn.iocoder.mall.productservice.manager.category.ProductCategoryManager; +import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO; +import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO; +import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO; +import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; +import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/7 + */ +@RestController +@RequestMapping("/product/category") +@Api("商品品牌") +public class ProductCategoryController { + @Autowired + private ProductCategoryManager productCategoryManager; + + + /** + * 创建商品分类 + * + * @param createDTO 创建商品分类 DTO + * @return 商品分类编号 + */ + @PostMapping("createProductCategory") + CommonResult createProductCategory(@RequestBody ProductCategoryCreateReqDTO createDTO){ + return success(productCategoryManager.createProductCategory(createDTO)); + } + + /** + * 更新商品分类 + * + * @param updateDTO 更新商品分类 DTO + */ + @PostMapping("updateProductCategory") + CommonResult updateProductCategory(@RequestBody ProductCategoryUpdateReqDTO updateDTO){ + productCategoryManager.updateProductCategory(updateDTO); + return success(true); + + } + + /** + * 删除商品分类 + * + * @param productCategoryId 商品分类编号 + */ + @GetMapping("deleteProductCategory") + CommonResult deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId){ + productCategoryManager.deleteProductCategory(productCategoryId); + return success(true); + } + + /** + * 获得商品分类 + * + * @param productCategoryId 商品分类编号 + * @return 商品分类 + */ + @GetMapping("getProductCategory") + CommonResult getProductCategory(@RequestParam("productCategoryId")Integer productCategoryId){ + return success(productCategoryManager.getProductCategory(productCategoryId)); + } + + /** + * 获得商品分类列表 + * + * @param productCategoryIds 商品分类编号列表 + * @return 商品分类列表 + */ + @GetMapping("listProductCategoriesByIds") + CommonResult> listProductCategoriesByIds(@RequestParam("productCategoryIds")Collection productCategoryIds){ + return success(productCategoryManager.listProductCategories(productCategoryIds)); + } + + /** + * 获得符合条件的商品分类列表 + * + * @return 商品分类列表 + */ + @PostMapping("listProductCategories") + CommonResult> listProductCategories(@RequestBody ProductCategoryListQueryReqDTO listQueryReqDTO){ + return success(productCategoryManager.listProductCategories(listQueryReqDTO)); + + } + + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpcImpl.java deleted file mode 100644 index 4d9bc930c..000000000 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandRpcImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.brand; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO; -import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO; -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; - -/** -* 商品品牌 Rpc 实现类 -*/ -@DubboService -public class ProductBrandRpcImpl implements ProductBrandRpc { - - @Autowired - private ProductBrandManager productBrandManager; - - @Override - public CommonResult createProductBrand(ProductBrandCreateReqDTO createDTO) { - return success(productBrandManager.createProductBrand(createDTO)); - } - - @Override - public CommonResult updateProductBrand(ProductBrandUpdateReqDTO updateDTO) { - productBrandManager.updateProductBrand(updateDTO); - return success(true); - } - - @Override - public CommonResult deleteProductBrand(Integer productBrandId) { - productBrandManager.deleteProductBrand(productBrandId); - return success(true); - } - - @Override - public CommonResult getProductBrand(Integer productBrandId) { - return success(productBrandManager.getProductBrand(productBrandId)); - } - - @Override - public CommonResult> listProductBrands(List productBrandIds) { - return success(productBrandManager.listProductBrands(productBrandIds)); - } - - @Override - public CommonResult> pageProductBrand(ProductBrandPageReqDTO pageDTO) { - return success(productBrandManager.pageProductBrand(pageDTO)); - } - -} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpcImpl.java deleted file mode 100644 index c3209145d..000000000 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/category/ProductCategoryRpcImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.category; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.manager.category.ProductCategoryManager; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; -import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** -* 商品分类 Rpc 实现类 -*/ -@DubboService -public class ProductCategoryRpcImpl implements ProductCategoryRpc { - - @Autowired - private ProductCategoryManager productCategoryManager; - - @Override - public CommonResult createProductCategory(ProductCategoryCreateReqDTO createDTO) { - return success(productCategoryManager.createProductCategory(createDTO)); - } - - @Override - public CommonResult updateProductCategory(ProductCategoryUpdateReqDTO updateDTO) { - productCategoryManager.updateProductCategory(updateDTO); - return success(true); - } - - @Override - public CommonResult deleteProductCategory(Integer productCategoryId) { - productCategoryManager.deleteProductCategory(productCategoryId); - return success(true); - } - - @Override - public CommonResult getProductCategory(Integer productCategoryId) { - return success(productCategoryManager.getProductCategory(productCategoryId)); - } - - @Override - public CommonResult> listProductCategories(Collection productCategoryIds) { - return success(productCategoryManager.listProductCategories(productCategoryIds)); - } - - @Override - public CommonResult> listProductCategories(ProductCategoryListQueryReqDTO listQueryReqDTO) { - return success(productCategoryManager.listProductCategories(listQueryReqDTO)); - } - -} diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java index 92d8e7935..cc7ee0799 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.searchservice.manager.product; import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc; +import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; @@ -35,9 +35,9 @@ public class SearchProductManager { @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") private ProductSkuRpc productSkuRpc; - @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private ProductCategoryRpc productCategoryRpc; + @Autowired + private ProductCategoryFeign productCategoryFeign; @Autowired private ProductSpuFeign productSpuFeign; @@ -110,7 +110,7 @@ public class SearchProductManager { } // 获得商品分类 CommonResult getProductCategoryResult = - productCategoryRpc.getProductCategory(productSpuResult.getData().getCid()); + productCategoryFeign.getProductCategory(productSpuResult.getData().getCid()); getProductCategoryResult.checkError(); if (getProductCategoryResult.getData() == null) { log.error("[saveProduct][商品 SPU({}) 的分类({}) 不存在]", id, productSpuResult.getData().getCid()); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductCategoryManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductCategoryManager.java index b9a48a923..503105b8e 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductCategoryManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductCategoryManager.java @@ -2,12 +2,12 @@ package cn.iocoder.mall.shopweb.service.product; import cn.iocoder.common.framework.enums.CommonStatusEnum; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc; +import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import cn.iocoder.mall.shopweb.controller.product.vo.category.ProductCategoryRespVO; import cn.iocoder.mall.shopweb.convert.product.ProductCategoryConvert; -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,11 +20,12 @@ import java.util.List; @Validated public class ProductCategoryManager { - @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private ProductCategoryRpc productCategoryRpc; + + @Autowired + private ProductCategoryFeign productCategoryFeign; public List listProductCategories(Integer pid) { - CommonResult> listProductCategoriesResult = productCategoryRpc.listProductCategories( + CommonResult> listProductCategoriesResult = productCategoryFeign.listProductCategories( new ProductCategoryListQueryReqDTO().setPid(pid).setStatus(CommonStatusEnum.ENABLE.getValue())); listProductCategoriesResult.checkError(); return ProductCategoryConvert.INSTANCE.convertList(listProductCategoriesResult.getData()); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSpuManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSpuManager.java index 13f16cb4b..b8d44c3ee 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSpuManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSpuManager.java @@ -4,7 +4,7 @@ import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.enums.spu.ProductSpuDetailFieldEnum; -import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc; +import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuDetailRespDTO; @@ -37,9 +37,9 @@ public class ProductSpuManager { @DubboReference(version = "${dubbo.consumer.SearchProductRpc.version}") private SearchProductRpc searchProductRpc; - @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private ProductCategoryRpc productCategoryRpc; + @Autowired + private ProductCategoryFeign productCategoryFeign; @Autowired private ProductSpuFeign productSpuFeign; @@ -62,7 +62,7 @@ public class ProductSpuManager { conditionRespVO.setCategories(Collections.emptyList()); } else { CommonResult> listProductCategoriesResult = - productCategoryRpc.listProductCategories(getSearchProductConditionResult.getData().getCids()); + productCategoryFeign.listProductCategoriesByIds(getSearchProductConditionResult.getData().getCids()); listProductCategoriesResult.checkError(); conditionRespVO.setCategories(ProductSpuConvert.INSTANCE.convertList(listProductCategoriesResult.getData())); }