From c50f99e7b3a36383dc9d805e61f2c8870183bd3e Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Wed, 6 Oct 2021 22:50:17 +0800
Subject: [PATCH 01/82] =?UTF-8?q?SPU.get=E6=8E=A5=E5=8F=A3=E6=94=B9?=
=?UTF-8?q?=E9=80=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/setup/quick-start.md | 2 +-
management-web-app/pom.xml | 5 +++
.../ManagementWebApplication.java | 4 +++
.../product/ProductSpuController.http | 8 +++++
.../managementweb/feign/ProductSpuFeign.java | 20 ++++++++++++
.../manager/product/ProductSpuManager.java | 7 ++++-
.../src/main/resources/application-dev.yml | 6 ++--
.../src/main/resources/application-local.yml | 6 ++--
.../main/resources/config/application.yaml | 2 +-
.../main/resources/config/application.yaml | 2 +-
.../src/main/resources/application-dev.yaml | 10 +++---
.../src/main/resources/application-local.yaml | 12 +++----
.../src/main/resources/application.yaml | 2 +-
.../common/dubbo/DubboGenericInvokerTest.java | 2 +-
.../product-service-api/pom.xml | 5 +++
.../product-service-app/pom.xml | 4 +++
.../ProductServiceApplication.java | 4 +++
.../controller/ProductSpuController.http | 4 +++
.../controller/SpuController.java | 31 +++++++++++++++++++
.../src/main/resources/application-dev.yaml | 10 +++---
.../src/main/resources/application-local.yaml | 10 +++---
.../src/main/resources/application.yaml | 2 +-
.../src/main/resources/application-dev.yaml | 10 +++---
.../src/main/resources/application-local.yaml | 10 +++---
.../src/main/resources/application.yaml | 2 +-
.../src/main/resources/application-dev.yaml | 6 ++--
.../src/main/resources/application-local.yaml | 6 ++--
.../src/main/resources/application.yaml | 6 ++--
.../src/main/resources/application-dev.yml | 6 ++--
.../src/main/resources/application-local.yml | 6 ++--
.../src/main/resources/application-dev.yaml | 12 +++----
.../src/main/resources/application-local.yaml | 12 +++----
.../src/main/resources/application-dev.yaml | 10 +++---
.../src/main/resources/application-local.yaml | 10 +++---
.../src/main/resources/application.yaml | 2 +-
.../src/main/resources/application-dev.yaml | 10 +++---
.../src/main/resources/application-local.yaml | 10 +++---
37 files changed, 183 insertions(+), 93 deletions(-)
create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
diff --git a/docs/setup/quick-start.md b/docs/setup/quick-start.md
index c92cd8f69..f7657464f 100644
--- a/docs/setup/quick-start.md
+++ b/docs/setup/quick-start.md
@@ -44,7 +44,7 @@ spring:
url: jdbc:mysql://s1.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8 # 请修改成你本地的 MySQL url
driver-class-name: com.mysql.jdbc.Driver
username: root # 请修改成你本地的 MySQL username
- password: 3WLiVUBEwTbvAfsh # 请修改成你本地的 MySQL password
+ password: zhuyang # 请修改成你本地的 MySQL password
```
# 4. Zookeeper
diff --git a/management-web-app/pom.xml b/management-web-app/pom.xml
index 06b23a98b..bed43c5dd 100644
--- a/management-web-app/pom.xml
+++ b/management-web-app/pom.xml
@@ -106,6 +106,11 @@
mapstruct-jdk8
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
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 121979533..6812bb727 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
@@ -2,8 +2,12 @@ package cn.iocoder.mall.managementweb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
public class ManagementWebApplication {
public static void main(String[] args) {
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
index 00d3c8f3c..6ffb59c67 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
@@ -49,3 +49,11 @@ id=59&name=测试商品标题&description=测试商品描述&cid=637&sellPoint=
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
###
+
+### /product-spu/get
+GET http://127.0.0.1:18083/management-api/product-spu/get?productSpuId=32
+Content-Type: application/x-www-form-urlencoded
+Authorization:Bearer yudaoyuanma
+
+###
+
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
new file mode 100644
index 000000000..2597badf5
--- /dev/null
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
@@ -0,0 +1,20 @@
+package cn.iocoder.mall.managementweb.feign;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(value = "product-service")
+public interface ProductSpuFeign {
+ /**
+ * 获得商品 SPU
+ *
+ * @param productSpuId 商品 SPU 编号
+ * @return 商品 SPU
+ */
+ @GetMapping(value = "/product/spu/get")
+ CommonResult getProductSpu(@RequestParam("productSpuId") Integer productSpuId);
+
+}
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
index 8655f307a..ef2c4d734 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
@@ -7,9 +7,11 @@ import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReq
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO;
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.product.ProductSpuConvert;
+import cn.iocoder.mall.managementweb.feign.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -23,6 +25,9 @@ public class ProductSpuManager {
@DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
private ProductSpuRpc productSpuRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
+
/**
* 创建商品 SPU
*
@@ -52,7 +57,7 @@ public class ProductSpuManager {
* @return 商品 SPU
*/
public ProductSpuRespVO getProductSpu(Integer productSpuId) {
- CommonResult getProductSpuResult = productSpuRpc.getProductSpu(productSpuId);
+ CommonResult getProductSpuResult = productSpuFeign.getProductSpu(productSpuId);
getProductSpuResult.checkError();
return ProductSpuConvert.INSTANCE.convert(getProductSpuResult.getData());
}
diff --git a/management-web-app/src/main/resources/application-dev.yml b/management-web-app/src/main/resources/application-dev.yml
index 31a3a702f..9e9f28fb7 100644
--- a/management-web-app/src/main/resources/application-dev.yml
+++ b/management-web-app/src/main/resources/application-dev.yml
@@ -4,15 +4,15 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Mall 认证安全配置
mall.security.admin.demo: true # 是否开启演示模式
diff --git a/management-web-app/src/main/resources/application-local.yml b/management-web-app/src/main/resources/application-local.yml
index 2e26cd388..fede4927b 100644
--- a/management-web-app/src/main/resources/application-local.yml
+++ b/management-web-app/src/main/resources/application-local.yml
@@ -4,12 +4,12 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/moved/product/product-service-impl/src/main/resources/config/application.yaml b/moved/product/product-service-impl/src/main/resources/config/application.yaml
index 66af9a899..10a3e9425 100644
--- a/moved/product/product-service-impl/src/main/resources/config/application.yaml
+++ b/moved/product/product-service-impl/src/main/resources/config/application.yaml
@@ -4,7 +4,7 @@ spring:
url: jdbc:mysql://s1.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
diff --git a/moved/system/system-service-impl/src/main/resources/config/application.yaml b/moved/system/system-service-impl/src/main/resources/config/application.yaml
index a44537f1e..bef7c0a02 100644
--- a/moved/system/system-service-impl/src/main/resources/config/application.yaml
+++ b/moved/system/system-service-impl/src/main/resources/config/application.yaml
@@ -4,7 +4,7 @@ spring:
url: jdbc:mysql://s1.iocoder.cn:3306/mall_admin?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
diff --git a/pay-service-project/pay-service-app/src/main/resources/application-dev.yaml b/pay-service-project/pay-service-app/src/main/resources/application-dev.yaml
index c7b4acbb6..faab4b01a 100644
--- a/pay-service-project/pay-service-app/src/main/resources/application-dev.yaml
+++ b/pay-service-project/pay-service-app/src/main/resources/application-dev.yaml
@@ -1,24 +1,24 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# XXL-Job 配置项
xxl:
diff --git a/pay-service-project/pay-service-app/src/main/resources/application-local.yaml b/pay-service-project/pay-service-app/src/main/resources/application-local.yaml
index b57d1302f..ffc81eb45 100644
--- a/pay-service-project/pay-service-app/src/main/resources/application-local.yaml
+++ b/pay-service-project/pay-service-app/src/main/resources/application-local.yaml
@@ -1,24 +1,24 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
@@ -28,7 +28,7 @@ xxl:
job:
enabled: false # 本地开发时,关闭 XXL-Job
admin:
- addresses: http://400-infra.server.iocoder.cn:9099
+ addresses: http://localhost:9099
executor:
appname: ${spring.application.name}
accessToken:
diff --git a/pay-service-project/pay-service-app/src/main/resources/application.yaml b/pay-service-project/pay-service-app/src/main/resources/application.yaml
index 57ba7cf4b..e35632ddf 100644
--- a/pay-service-project/pay-service-app/src/main/resources/application.yaml
+++ b/pay-service-project/pay-service-app/src/main/resources/application.yaml
@@ -46,7 +46,7 @@ dubbo:
# RocketMQ 配置项
rocketmq:
- name-server: 400-infra.server.iocoder.cn:9876
+ name-server: localhost:9876
producer:
group: ${spring.application.name}-producer-group
diff --git a/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/common/dubbo/DubboGenericInvokerTest.java b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/common/dubbo/DubboGenericInvokerTest.java
index 878c72956..603267cd7 100644
--- a/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/common/dubbo/DubboGenericInvokerTest.java
+++ b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/common/dubbo/DubboGenericInvokerTest.java
@@ -15,7 +15,7 @@ public class DubboGenericInvokerTest {
application.setName("api-generic-consumer");
RegistryConfig registry = new RegistryConfig();
- registry.setAddress("nacos://400-infra.server.iocoder.cn:8848?namespace=dev");
+ registry.setAddress("nacos://localhost:8848?namespace=dev");
application.setRegistry(registry);
diff --git a/product-service-project/product-service-api/pom.xml b/product-service-project/product-service-api/pom.xml
index e267473c8..1cbc81a0c 100644
--- a/product-service-project/product-service-api/pom.xml
+++ b/product-service-project/product-service-api/pom.xml
@@ -26,6 +26,11 @@
org.projectlombok
lombok
+
+ org.springframework.cloud
+ spring-cloud-openfeign-core
+ RELEASE
+
diff --git a/product-service-project/product-service-app/pom.xml b/product-service-project/product-service-app/pom.xml
index cafab548f..4c886ba44 100644
--- a/product-service-project/product-service-app/pom.xml
+++ b/product-service-project/product-service-app/pom.xml
@@ -102,6 +102,10 @@
aspectjweaver
1.9.6
+
+ io.swagger
+ swagger-annotations
+
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
index ac41a7aab..5c5c30edc 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
@@ -2,8 +2,12 @@ package cn.iocoder.mall.productservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
public class ProductServiceApplication {
public static void main(String[] args) {
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
new file mode 100644
index 000000000..48ef87dd1
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
@@ -0,0 +1,4 @@
+### /product/spu/get 获得商品 SPU
+GET http://localhost:38082/product/spu/get?productSpuId=32
+###
+
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
new file mode 100644
index 000000000..6f7fd7903
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
@@ -0,0 +1,31 @@
+package cn.iocoder.mall.productservice.controller;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.manager.spu.ProductSpuManager;
+import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import static cn.iocoder.common.framework.vo.CommonResult.success;
+
+@RestController
+@RequestMapping("/product/spu")
+@Api("商品spu")
+public class SpuController {
+ @Autowired
+ private ProductSpuManager productSpuManager;
+
+ @GetMapping("/get")
+ @ApiOperation("获得商品 SPU")
+ @ApiImplicitParam(name = "productSpuId", value = "商品 SPU 编号", required = true)
+ public CommonResult getProductSpu(@RequestParam(value="productSpuId") Integer productSpuId) {
+ return success(productSpuManager.getProductSpu(productSpuId));
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/resources/application-dev.yaml b/product-service-project/product-service-app/src/main/resources/application-dev.yaml
index 8d210f360..7256a5bb2 100644
--- a/product-service-project/product-service-app/src/main/resources/application-dev.yaml
+++ b/product-service-project/product-service-app/src/main/resources/application-dev.yaml
@@ -1,21 +1,21 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/product-service-project/product-service-app/src/main/resources/application-local.yaml b/product-service-project/product-service-app/src/main/resources/application-local.yaml
index 099913a16..8c2752534 100644
--- a/product-service-project/product-service-app/src/main/resources/application-local.yaml
+++ b/product-service-project/product-service-app/src/main/resources/application-local.yaml
@@ -1,24 +1,24 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/product-service-project/product-service-app/src/main/resources/application.yaml b/product-service-project/product-service-app/src/main/resources/application.yaml
index e169a0bfa..296e61a84 100644
--- a/product-service-project/product-service-app/src/main/resources/application.yaml
+++ b/product-service-project/product-service-app/src/main/resources/application.yaml
@@ -42,7 +42,7 @@ dubbo:
# RocketMQ 配置项
rocketmq:
- name-server: 400-infra.server.iocoder.cn:9876
+ name-server: localhost:9876
producer:
group: ${spring.application.name}-producer-group
diff --git a/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml b/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml
index 99a349fac..946ea52b2 100644
--- a/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml
+++ b/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml
@@ -1,21 +1,21 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml b/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml
index 19e0f347a..43bff1671 100644
--- a/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml
+++ b/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml
@@ -1,24 +1,24 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/promotion-service-project/promotion-service-app/src/main/resources/application.yaml b/promotion-service-project/promotion-service-app/src/main/resources/application.yaml
index 542011fa4..10d90e898 100644
--- a/promotion-service-project/promotion-service-app/src/main/resources/application.yaml
+++ b/promotion-service-project/promotion-service-app/src/main/resources/application.yaml
@@ -46,7 +46,7 @@ dubbo:
# RocketMQ 配置项
rocketmq:
- name-server: 400-infra.server.iocoder.cn:9876
+ name-server: localhost:9876
producer:
group: ${spring.application.name}-producer-group
diff --git a/search-service-project/search-service-app/src/main/resources/application-dev.yaml b/search-service-project/search-service-app/src/main/resources/application-dev.yaml
index 2e26cd388..fede4927b 100644
--- a/search-service-project/search-service-app/src/main/resources/application-dev.yaml
+++ b/search-service-project/search-service-app/src/main/resources/application-dev.yaml
@@ -4,12 +4,12 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/search-service-project/search-service-app/src/main/resources/application-local.yaml b/search-service-project/search-service-app/src/main/resources/application-local.yaml
index 9c125c50b..07ae5f036 100644
--- a/search-service-project/search-service-app/src/main/resources/application-local.yaml
+++ b/search-service-project/search-service-app/src/main/resources/application-local.yaml
@@ -4,15 +4,15 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/search-service-project/search-service-app/src/main/resources/application.yaml b/search-service-project/search-service-app/src/main/resources/application.yaml
index 8b1f96473..71b38c6bf 100644
--- a/search-service-project/search-service-app/src/main/resources/application.yaml
+++ b/search-service-project/search-service-app/src/main/resources/application.yaml
@@ -9,12 +9,12 @@ spring:
data:
elasticsearch:
cluster-name: elasticsearch
- cluster-nodes: 400-infra.server.iocoder.cn:9300
+ cluster-nodes: localhost:9300
repositories:
enable: true
elasticsearch:
rest:
- uris: 400-infra.server.iocoder.cn:9200
+ uris: localhost:9200
# Dubbo 配置项
dubbo:
@@ -46,7 +46,7 @@ dubbo:
# RocketMQ 配置项
rocketmq:
- name-server: 400-infra.server.iocoder.cn:9876
+ name-server: localhost:9876
# Actuator 监控配置项
management:
diff --git a/shop-web-app/src/main/resources/application-dev.yml b/shop-web-app/src/main/resources/application-dev.yml
index 2e26cd388..fede4927b 100644
--- a/shop-web-app/src/main/resources/application-dev.yml
+++ b/shop-web-app/src/main/resources/application-dev.yml
@@ -4,12 +4,12 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/shop-web-app/src/main/resources/application-local.yml b/shop-web-app/src/main/resources/application-local.yml
index 12e9ed401..d8b2b0c81 100644
--- a/shop-web-app/src/main/resources/application-local.yml
+++ b/shop-web-app/src/main/resources/application-local.yml
@@ -4,7 +4,7 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Spring 主应用配置
main:
@@ -14,5 +14,5 @@ spring:
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/system-service-project/system-service-app/src/main/resources/application-dev.yaml b/system-service-project/system-service-app/src/main/resources/application-dev.yaml
index 5f93d363a..c6c91d9e7 100644
--- a/system-service-project/system-service-app/src/main/resources/application-dev.yaml
+++ b/system-service-project/system-service-app/src/main/resources/application-dev.yaml
@@ -1,14 +1,14 @@
spring:
# MySQL 配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Redis 配置
redis:
- host: 400-infra.server.iocoder.cn
+ host: localhost
port: 6379
database: 0
@@ -17,12 +17,12 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/system-service-project/system-service-app/src/main/resources/application-local.yaml b/system-service-project/system-service-app/src/main/resources/application-local.yaml
index b59d19223..4a3ed5fd4 100644
--- a/system-service-project/system-service-app/src/main/resources/application-local.yaml
+++ b/system-service-project/system-service-app/src/main/resources/application-local.yaml
@@ -1,14 +1,14 @@
spring:
# MySQL 配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Redis 配置
redis:
- host: 400-infra.server.iocoder.cn
+ host: localhost
port: 6379
database: 0
@@ -17,15 +17,15 @@ spring:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/trade-service-project/trade-service-app/src/main/resources/application-dev.yaml b/trade-service-project/trade-service-app/src/main/resources/application-dev.yaml
index 6359e3363..a371d4a54 100644
--- a/trade-service-project/trade-service-app/src/main/resources/application-dev.yaml
+++ b/trade-service-project/trade-service-app/src/main/resources/application-dev.yaml
@@ -1,21 +1,21 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_trade?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_trade?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/trade-service-project/trade-service-app/src/main/resources/application-local.yaml b/trade-service-project/trade-service-app/src/main/resources/application-local.yaml
index da9304ac3..99ebfb162 100644
--- a/trade-service-project/trade-service-app/src/main/resources/application-local.yaml
+++ b/trade-service-project/trade-service-app/src/main/resources/application-local.yaml
@@ -1,16 +1,16 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_trade?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_trade?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# # Spring 主应用配置
# main:
@@ -20,8 +20,8 @@ spring:
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/trade-service-project/trade-service-app/src/main/resources/application.yaml b/trade-service-project/trade-service-app/src/main/resources/application.yaml
index 41e0ac3ce..fe35cf834 100644
--- a/trade-service-project/trade-service-app/src/main/resources/application.yaml
+++ b/trade-service-project/trade-service-app/src/main/resources/application.yaml
@@ -52,7 +52,7 @@ dubbo:
# RocketMQ 配置项
rocketmq:
- name-server: 400-infra.server.iocoder.cn:9876
+ name-server: localhost:9876
producer:
group: ${spring.application.name}-producer-group
diff --git a/user-service-project/user-service-app/src/main/resources/application-dev.yaml b/user-service-project/user-service-app/src/main/resources/application-dev.yaml
index e08317307..32a4152b1 100644
--- a/user-service-project/user-service-app/src/main/resources/application-dev.yaml
+++ b/user-service-project/user-service-app/src/main/resources/application-dev.yaml
@@ -1,21 +1,21 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_user?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_user?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
- # address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
diff --git a/user-service-project/user-service-app/src/main/resources/application-local.yaml b/user-service-project/user-service-app/src/main/resources/application-local.yaml
index 6a89f36d2..85a689310 100644
--- a/user-service-project/user-service-app/src/main/resources/application-local.yaml
+++ b/user-service-project/user-service-app/src/main/resources/application-local.yaml
@@ -1,24 +1,24 @@
spring:
# 数据源配置项
datasource:
- url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_user?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
+ url: jdbc:mysql://localhost:3306/mall_user?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: 3WLiVUBEwTbvAfsh
+ password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
- server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
-# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
- address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组
From 4f50845b66d00eaf304e683da66f7afcd65233ed Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Thu, 7 Oct 2021 16:50:40 +0800
Subject: [PATCH 02/82] =?UTF-8?q?1.=20ProductSPU=20=E8=BF=81=E7=A7=BBsprin?=
=?UTF-8?q?gcloud.=202.=20=E8=B0=83=E7=94=A8=E6=96=B9manager=E9=80=9A?=
=?UTF-8?q?=E8=BF=87feign=E8=B0=83=E7=94=A8spu=20api?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ManagementWebApplication.java | 2 +-
.../product/ProductSpuController.http | 22 +++--
.../managementweb/feign/ProductSpuFeign.java | 20 ----
.../manager/product/ProductSpuManager.java | 14 +--
.../recommend/ProductRecommendManager.java | 10 +-
.../rpc/spu/ProductSpuFeign.java | 77 ++++++++++++++++
.../productservice/rpc/spu/ProductSpuRpc.java | 65 -------------
.../controller/ProductSpuController.http | 9 ++
.../controller/ProductSpuController.java | 91 +++++++++++++++++++
.../controller/SpuController.java | 31 -------
.../rpc/spu/ProductSpuRpcImpl.java | 60 ------------
.../promotion-service-app/pom.xml | 4 +
.../PromotionServiceApplication.java | 4 +
.../manager/price/PriceManager.java | 12 ++-
.../recommend/ProductRecommendManager.java | 9 +-
.../search-service-app/pom.xml | 4 +
.../SearchServiceApplication.java | 4 +
.../manager/product/SearchProductManager.java | 11 ++-
shop-web-app/pom.xml | 5 +-
.../mall/shopweb/ShopWebApplication.java | 4 +
.../product/ProductSpuController.http | 6 +-
.../service/product/ProductSpuManager.java | 9 +-
.../promotion/ProductRecommendManager.java | 9 +-
23 files changed, 256 insertions(+), 226 deletions(-)
delete mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java
delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.java
delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.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 6812bb727..0c15ca0e9 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,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
-@EnableFeignClients
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
public class ManagementWebApplication {
public static void main(String[] args) {
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
index 6ffb59c67..301e8f1aa 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
@@ -1,7 +1,7 @@
### /product-spu/page 成功(全部)
-GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10
+GET http://127.0.0.1:18083/management-api/product-spu/page?pageNo=1&pageSize=100
Content-Type: application/x-www-form-urlencoded
-Authorization: Bearer {{accessToken}}
+Authorization: Bearer yudaoyuanma
### /product-spu/page 成功(有库存 + 上架)
GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10&hasQuantity=true&visible=true
@@ -14,11 +14,11 @@ Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {{accessToken}}
### /product-spu/create 成功
-POST {{baseUrl}}/product-spu/create
+POST http://127.0.0.1:18083/management-api/product-spu/create
Content-Type: application/x-www-form-urlencoded
-Authorization: Bearer {{accessToken}}
+Authorization: Bearer yudaoyuanma
-name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
+name=新商品&description=新商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
@@ -40,11 +40,11 @@ name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&pic
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=1,2,4
### /product-spu/update 成功
-POST {{baseUrl}}/product-spu/update
+POST http://127.0.0.1:18083/management-api/product-spu/update
Content-Type: application/x-www-form-urlencoded
-Authorization: Bearer {{accessToken}}
+Authorization: Bearer yudaoyuanma
-id=59&name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
+id=64&name=新商品测试&description=新商品测试&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
@@ -57,3 +57,9 @@ Authorization:Bearer yudaoyuanma
###
+### /product-spu/get
+GET http://127.0.0.1:18083/management-api/product-spu/list?productSpuIds=32,33,34
+Content-Type: application/x-www-form-urlencoded
+Authorization:Bearer yudaoyuanma
+
+###
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
deleted file mode 100644
index 2597badf5..000000000
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.iocoder.mall.managementweb.feign;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@FeignClient(value = "product-service")
-public interface ProductSpuFeign {
- /**
- * 获得商品 SPU
- *
- * @param productSpuId 商品 SPU 编号
- * @return 商品 SPU
- */
- @GetMapping(value = "/product/spu/get")
- CommonResult getProductSpu(@RequestParam("productSpuId") Integer productSpuId);
-
-}
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
index ef2c4d734..c61d7c87b 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
@@ -7,10 +7,8 @@ import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReq
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO;
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.product.ProductSpuConvert;
-import cn.iocoder.mall.managementweb.feign.ProductSpuFeign;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
-import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -22,8 +20,6 @@ import java.util.List;
@Service
public class ProductSpuManager {
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
@Autowired
private ProductSpuFeign productSpuFeign;
@@ -35,7 +31,7 @@ public class ProductSpuManager {
* @return 商品 SPU
*/
public Integer createProductSpu(ProductSpuCreateReqVO createVO) {
- CommonResult createProductSpuResult = productSpuRpc.createProductSpu(ProductSpuConvert.INSTANCE.convert(createVO));
+ CommonResult createProductSpuResult = productSpuFeign.createProductSpu(ProductSpuConvert.INSTANCE.convert(createVO));
createProductSpuResult.checkError();
return createProductSpuResult.getData();
}
@@ -46,7 +42,7 @@ public class ProductSpuManager {
* @param updateVO 更新商品 SPU VO
*/
public void updateProductSpu(ProductSpuUpdateReqVO updateVO) {
- CommonResult updateProductSpuResult = productSpuRpc.updateProductSpu(ProductSpuConvert.INSTANCE.convert(updateVO));
+ CommonResult updateProductSpuResult = productSpuFeign.updateProductSpu(ProductSpuConvert.INSTANCE.convert(updateVO));
updateProductSpuResult.checkError();
}
@@ -69,7 +65,7 @@ public class ProductSpuManager {
* @return 商品 SPU列表
*/
public List listProductSpus(List productSpuIds) {
- CommonResult> listProductSpuResult = productSpuRpc.listProductSpus(productSpuIds);
+ CommonResult> listProductSpuResult = productSpuFeign.listProductSpus(productSpuIds);
listProductSpuResult.checkError();
return ProductSpuConvert.INSTANCE.convertList(listProductSpuResult.getData());
}
@@ -81,7 +77,7 @@ public class ProductSpuManager {
* @return 商品 SPU分页结果
*/
public PageResult pageProductSpu(ProductSpuPageReqVO pageVO) {
- CommonResult> pageProductSpuResult = productSpuRpc.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageVO));
+ CommonResult> pageProductSpuResult = productSpuFeign.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageVO));
pageProductSpuResult.checkError();
return ProductSpuConvert.INSTANCE.convertPage(pageProductSpuResult.getData());
}
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 0a3c686b6..6bd4b7a99 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
@@ -8,11 +8,12 @@ import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRe
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+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.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;
@@ -28,9 +29,8 @@ public class ProductRecommendManager {
@DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}")
private ProductRecommendRpc productRecommendRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
-
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
/**
* 创建商品推荐
*
@@ -78,7 +78,7 @@ public class ProductRecommendManager {
PageResult pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData());
if (!CollectionUtils.isEmpty(pageResult.getList())) {
// 获取商品信息,并进行拼接
- CommonResult> listProductSpusResult = productSpuRpc.listProductSpus(
+ CommonResult> listProductSpusResult = productSpuFeign.listProductSpus(
CollectionUtils.convertSet(pageResult.getList(), ProductRecommendDetailVO::getProductSpuId));
listProductSpusResult.checkError();
Map productSpuMap = CollectionUtils.convertMap(listProductSpusResult.getData(), ProductSpuRespDTO::getId);
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java
new file mode 100644
index 000000000..413cd2891
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java
@@ -0,0 +1,77 @@
+package cn.iocoder.mall.productservice.rpc.spu;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.common.framework.vo.PageResult;
+import cn.iocoder.mall.productservice.rpc.spu.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.Collection;
+import java.util.List;
+
+@FeignClient(value = "product-service")
+public interface ProductSpuFeign {
+ /**
+ * 获得商品 SPU
+ *
+ * @param productSpuId 商品 SPU 编号
+ * @return 商品 SPU
+ */
+ @GetMapping(value = "/product/spu/get")
+ CommonResult getProductSpu(@RequestParam("productSpuId") Integer productSpuId);
+
+
+
+ /**
+ * 创建商品 SPU
+ *
+ * @param createDTO 创建商品 SPU DTO
+ * @return 商品 SPU编号
+ */
+ @PostMapping(value = "/product/spu/create")
+ CommonResult createProductSpu(@RequestBody ProductSpuAndSkuCreateReqDTO createDTO);
+
+ /**
+ * 更新商品 SPU
+ *
+ * @param updateDTO 更新商品 SPU DTO
+ */
+ @PostMapping(value = "/product/spu/update")
+ CommonResult updateProductSpu(@RequestBody ProductSpuAndSkuUpdateReqDTO updateDTO);
+
+
+ /**
+ * 获得商品 SPU列表
+ *
+ * @param productSpuIds 商品 SPU 编号列表
+ * @return 商品 SPU 列表
+ */
+ @GetMapping(value = "/product/spu/list")
+ CommonResult> listProductSpus(@RequestParam("productSpuIds") Collection productSpuIds);
+
+ /**
+ * 获得商品 SPU 分页
+ *
+ * @param pageDTO 商品 SPU 分页查询
+ * @return 商品 SPU 分页结果
+ */
+ @PostMapping(value = "/product/spu/page")
+ CommonResult> pageProductSpu(@RequestBody ProductSpuPageReqDTO pageDTO);
+
+ /**
+ * 顺序获得商品 SPU 编号数组
+ *
+ * @param lastSpuId 最后一个商品 SPU 编号
+ * @param limit 数量
+ * @return 商品 SPU 编号数组
+ */
+ @GetMapping(value = "/product/spu/lislistProductSpuIdst")
+ CommonResult> listProductSpuIds(@RequestParam("lastSpuId")Integer lastSpuId, @RequestParam("limit")Integer limit);
+
+ @GetMapping(value = "/product/spu/getProductSpuDetail")
+ CommonResult getProductSpuDetail(@RequestParam("productSpuId") Integer productSpuId,@RequestParam("fields") Collection fields);
+
+}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java
deleted file mode 100644
index 792e16a89..000000000
--- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.spu;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.productservice.rpc.spu.dto.*;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
-* 商品 SPU Rpc 接口
-*/
-public interface ProductSpuRpc {
-
- /**
- * 创建商品 SPU
- *
- * @param createDTO 创建商品 SPU DTO
- * @return 商品 SPU编号
- */
- CommonResult createProductSpu(ProductSpuAndSkuCreateReqDTO createDTO);
-
- /**
- * 更新商品 SPU
- *
- * @param updateDTO 更新商品 SPU DTO
- */
- CommonResult updateProductSpu(ProductSpuAndSkuUpdateReqDTO updateDTO);
-
- /**
- * 获得商品 SPU
- *
- * @param productSpuId 商品 SPU 编号
- * @return 商品 SPU
- */
- CommonResult getProductSpu(Integer productSpuId);
-
- /**
- * 获得商品 SPU列表
- *
- * @param productSpuIds 商品 SPU 编号列表
- * @return 商品 SPU 列表
- */
- CommonResult> listProductSpus(Collection productSpuIds);
-
- /**
- * 获得商品 SPU 分页
- *
- * @param pageDTO 商品 SPU 分页查询
- * @return 商品 SPU 分页结果
- */
- CommonResult> pageProductSpu(ProductSpuPageReqDTO pageDTO);
-
- /**
- * 顺序获得商品 SPU 编号数组
- *
- * @param lastSpuId 最后一个商品 SPU 编号
- * @param limit 数量
- * @return 商品 SPU 编号数组
- */
- CommonResult> listProductSpuIds(Integer lastSpuId, Integer limit);
-
- CommonResult getProductSpuDetail(Integer productSpuId, Collection fields);
-
-}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
index 48ef87dd1..97e2ed394 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
@@ -2,3 +2,12 @@
GET http://localhost:38082/product/spu/get?productSpuId=32
###
+### /product/spu/get 获得商品 SPU
+GET http://localhost:38082/product/spu/lislistProductSpuIdst?lastSpuId=30&limit=10
+###
+
+
+### /product/spu/get 获得商品 SPU
+GET http://localhost:38082/product/spu/getProductSpuDetail?productSpuId=32&fields=attr,sku
+###
+
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.java
new file mode 100644
index 000000000..eb58b972f
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.java
@@ -0,0 +1,91 @@
+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.spu.ProductSpuManager;
+import cn.iocoder.mall.productservice.rpc.spu.dto.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+import java.util.Collection;
+import java.util.List;
+
+import static cn.iocoder.common.framework.vo.CommonResult.success;
+
+@RestController
+@RequestMapping("/product/spu")
+@Api("商品spu")
+public class ProductSpuController {
+ @Autowired
+ private ProductSpuManager productSpuManager;
+
+ @GetMapping("/get")
+ @ApiOperation("获得商品 SPU")
+ @ApiImplicitParam(name = "productSpuId", value = "商品 SPU 编号", required = true)
+ public CommonResult getProductSpu(@RequestParam(value="productSpuId") Integer productSpuId) {
+ return success(productSpuManager.getProductSpu(productSpuId));
+ }
+
+ /**
+ * 更新商品 SPU
+ *
+ * @param updateDTO 更新商品 SPU DTO
+ */
+ @PostMapping("/update")
+ @ApiOperation("更新商品 SPU")
+ public CommonResult updateProductSpu(@Valid @RequestBody ProductSpuAndSkuUpdateReqDTO updateDTO) {
+ productSpuManager.updateProductSpu(updateDTO);
+ return success(true);
+ }
+
+ @PostMapping("/create")
+ @ApiOperation("创建商品 SPU")
+ public CommonResult createProductSpu(@Valid @RequestBody ProductSpuAndSkuCreateReqDTO createDTO) {
+ return success(productSpuManager.createProductSpu(createDTO));
+ }
+
+ @GetMapping("/list")
+ @ApiOperation("获得商品 SPU 列表")
+ @ApiImplicitParam(name = "productSpuIds", value = "商品 SPU 编号列表", required = true)
+ public CommonResult> listProductSpus(@RequestParam("productSpuIds") List productSpuIds) {
+ return success(productSpuManager.listProductSpus(productSpuIds));
+ }
+
+ @PostMapping("/page")
+ @ApiOperation("获得商品 SPU 分页")
+ public CommonResult> pageProductSpu(@RequestBody ProductSpuPageReqDTO pageVO) {
+ // 全部:无搜索条件
+ // 在售中:visible = true && hasQuantity = true
+ // 已售罄:visible = true && hasQuantity = false
+ // 仓库中:visible = false
+ return success(productSpuManager.pageProductSpu(pageVO));
+ }
+
+
+ /**
+ * 顺序获得商品 SPU 编号数组
+ *
+ * @param lastSpuId 最后一个商品 SPU 编号
+ * @param limit 数量
+ * @return 商品 SPU 编号数组
+ */
+ @GetMapping("/lislistProductSpuIdst")
+ public CommonResult> lislistProductSpuIdst(@RequestParam("lastSpuId")Integer lastSpuId, @RequestParam("limit")Integer limit) {
+ // 全部:无搜索条件
+ // 在售中:visible = true && hasQuantity = true
+ // 已售罄:visible = true && hasQuantity = false
+ // 仓库中:visible = false
+ return success(productSpuManager.listProductSpuIds(lastSpuId, limit));
+ }
+
+
+ @GetMapping("/getProductSpuDetail")
+ public CommonResult getProductSpuDetail(@RequestParam("productSpuId") Integer productSpuId,@RequestParam("fields") Collection fields) {
+ return success(productSpuManager.getProductSpuDetail(productSpuId,fields));
+ }
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
deleted file mode 100644
index 6f7fd7903..000000000
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.iocoder.mall.productservice.controller;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.manager.spu.ProductSpuManager;
-import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-@RestController
-@RequestMapping("/product/spu")
-@Api("商品spu")
-public class SpuController {
- @Autowired
- private ProductSpuManager productSpuManager;
-
- @GetMapping("/get")
- @ApiOperation("获得商品 SPU")
- @ApiImplicitParam(name = "productSpuId", value = "商品 SPU 编号", required = true)
- public CommonResult getProductSpu(@RequestParam(value="productSpuId") Integer productSpuId) {
- return success(productSpuManager.getProductSpu(productSpuId));
- }
-
-}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java
deleted file mode 100644
index a00d969ae..000000000
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.spu;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.productservice.manager.spu.ProductSpuManager;
-import cn.iocoder.mall.productservice.rpc.spu.dto.*;
-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;
-
-/**
-* 商品 SPU Rpc 实现类
-*/
-@DubboService
-public class ProductSpuRpcImpl implements ProductSpuRpc {
-
- @Autowired
- private ProductSpuManager productSpuManager;
-
- @Override
- public CommonResult createProductSpu(ProductSpuAndSkuCreateReqDTO createDTO) {
- return success(productSpuManager.createProductSpu(createDTO));
- }
-
- @Override
- public CommonResult updateProductSpu(ProductSpuAndSkuUpdateReqDTO updateDTO) {
- productSpuManager.updateProductSpu(updateDTO);
- return success(true);
- }
-
- @Override
- public CommonResult getProductSpu(Integer productSpuId) {
- return success(productSpuManager.getProductSpu(productSpuId));
- }
-
- @Override
- public CommonResult> listProductSpus(Collection productSpuIds) {
- return success(productSpuManager.listProductSpus(productSpuIds));
- }
-
- @Override
- public CommonResult> pageProductSpu(ProductSpuPageReqDTO pageDTO) {
- return success(productSpuManager.pageProductSpu(pageDTO));
- }
-
- @Override
- public CommonResult> listProductSpuIds(Integer lastSpuId, Integer limit) {
- return success(productSpuManager.listProductSpuIds(lastSpuId, limit));
- }
-
- @Override
- public CommonResult getProductSpuDetail(Integer productSpuId, Collection fields) {
- return success(productSpuManager.getProductSpuDetail(productSpuId, fields));
- }
-
-}
diff --git a/promotion-service-project/promotion-service-app/pom.xml b/promotion-service-project/promotion-service-app/pom.xml
index 6e7818b88..2542b5202 100644
--- a/promotion-service-project/promotion-service-app/pom.xml
+++ b/promotion-service-project/promotion-service-app/pom.xml
@@ -104,6 +104,10 @@
aspectjweaver
1.9.6
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
index fc6422543..06143b6c9 100644
--- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
+++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
@@ -3,8 +3,12 @@ package cn.iocoder.mall.promotionservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
public class PromotionServiceApplication {
public static void main(String[] args) {
diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
index c63aab764..142851957 100644
--- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
+++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
@@ -6,9 +6,11 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
-import cn.iocoder.mall.promotion.api.enums.*;
+import cn.iocoder.mall.promotion.api.enums.MeetTypeEnum;
+import cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum;
+import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityStatusEnum;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityTypeEnum;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
@@ -36,8 +38,8 @@ public class PriceManager {
@DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
private ProductSkuRpc productSkuRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
@Autowired
private PromotionActivityService promotionActivityService;
@@ -95,7 +97,7 @@ public class PriceManager {
private List initCalcOrderPriceItems(List skus,
Map calcProductItemDTOMap) {
// 获得商品分类 Map
- CommonResult> listProductSpusResult = productSpuRpc.listProductSpus(CollectionUtils.convertSet(skus, ProductSkuRespDTO::getSpuId));
+ CommonResult> listProductSpusResult = productSpuFeign.listProductSpus(CollectionUtils.convertSet(skus, ProductSkuRespDTO::getSpuId));
listProductSpusResult.checkError();
Map spuIdCategoryIdMap = CollectionUtils.convertMap(listProductSpusResult.getData(), // SPU 编号与 Category 编号的映射
ProductSpuRespDTO::getId, ProductSpuRespDTO::getCid);
diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/recommend/ProductRecommendManager.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/recommend/ProductRecommendManager.java
index 9ca04e34b..4467dcc4a 100644
--- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/recommend/ProductRecommendManager.java
+++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/recommend/ProductRecommendManager.java
@@ -3,11 +3,10 @@ package cn.iocoder.mall.promotionservice.manager.recommend;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+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.dto.*;
import cn.iocoder.mall.promotionservice.service.recommend.ProductRecommendService;
-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,8 +22,8 @@ import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PR
@Validated
public class ProductRecommendManager {
- @DubboReference(validation = "true", version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
@Autowired
private ProductRecommendService productRecommendService;
@@ -56,7 +55,7 @@ public class ProductRecommendManager {
}
private void checkProductSpu(Integer productSpuId) {
- CommonResult getProductSpuResult = productSpuRpc.getProductSpu(productSpuId);
+ CommonResult getProductSpuResult = productSpuFeign.getProductSpu(productSpuId);
getProductSpuResult.checkError();
if (getProductSpuResult.getData() == null) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS);
diff --git a/search-service-project/search-service-app/pom.xml b/search-service-project/search-service-app/pom.xml
index c813f761d..45b0bbb42 100644
--- a/search-service-project/search-service-app/pom.xml
+++ b/search-service-project/search-service-app/pom.xml
@@ -101,6 +101,10 @@
aspectjweaver
1.9.6
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
index 96016368b..a0a162ac1 100644
--- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
@@ -2,8 +2,12 @@ package cn.iocoder.mall.searchservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
public class SearchServiceApplication {
public static void main(String[] args) {
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 19546f116..92d8e7935 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
@@ -8,7 +8,7 @@ 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;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.searchservice.convert.product.SearchProductConvert;
import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductConditionReqDTO;
@@ -33,13 +33,14 @@ public class SearchProductManager {
private static final Integer REBUILD_FETCH_PER_SIZE = 100;
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
@DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
private ProductSkuRpc productSkuRpc;
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
private ProductCategoryRpc productCategoryRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
+
// @DubboReference( version = "${dubbo.consumer.CartService.version}")
// private CartService cartService;
@@ -68,7 +69,7 @@ public class SearchProductManager {
int rebuildCounts = 0;
while (true) {
// 从商品服务,增量获取商品列表编号
- CommonResult> listProductSpuIdsResult = productSpuRpc.listProductSpuIds(lastId, REBUILD_FETCH_PER_SIZE);
+ CommonResult> listProductSpuIdsResult = productSpuFeign.listProductSpuIds(lastId, REBUILD_FETCH_PER_SIZE);
listProductSpuIdsResult.checkError();
List spuIds = listProductSpuIdsResult.getData();
// 逐个重建索引到 ES 中
@@ -93,7 +94,7 @@ public class SearchProductManager {
*/
public Boolean saveProduct(Integer id) {
// 获得商品 SPU
- CommonResult productSpuResult = productSpuRpc.getProductSpu(id);
+ CommonResult productSpuResult = productSpuFeign.getProductSpu(id);
productSpuResult.checkError();
if (productSpuResult.getData() == null) {
log.error("[saveProduct][商品 SPU({}) 不存在]", id);
diff --git a/shop-web-app/pom.xml b/shop-web-app/pom.xml
index b634fbf48..d649bfd9e 100644
--- a/shop-web-app/pom.xml
+++ b/shop-web-app/pom.xml
@@ -117,7 +117,10 @@
org.mapstruct
mapstruct-jdk8
-
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
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 8b0f5a02a..ca0a38146 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
@@ -2,8 +2,12 @@ package cn.iocoder.mall.shopweb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
public class ShopWebApplication {
public static void main(String[] args) {
diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.http b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.http
index 5ab67814f..c18e02753 100644
--- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.http
+++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.http
@@ -1,13 +1,13 @@
### /product-spu/page 成功(全部)
-GET {{shop-api-base-url}}/product-spu/page?pageNo=1&pageSize=10&keyword=骚气
+GET http://127.0.0.1:18084/shop-api/product-spu/page?pageNo=1&pageSize=10&keyword=骚气
Content-Type: application/x-www-form-urlencoded
### /product-spu/search-condition 成功
-GET {{shop-api-base-url}}/product-spu/search-condition?keyword=骚气
+GET http://127.0.0.1:18084/shop-api/product-spu/search-condition?keyword=骚气
Content-Type: application/x-www-form-urlencoded
### /product-spu/get-detail 成功
-GET {{shop-api-base-url}}/product-spu/get-detail?id=63
+GET http://127.0.0.1:18084/shop-api/product-spu/get-detail?id=63
Content-Type: application/x-www-form-urlencoded
###
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 02d0523da..13f16cb4b 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
@@ -6,7 +6,7 @@ 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.dto.ProductCategoryRespDTO;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuDetailRespDTO;
import cn.iocoder.mall.searchservice.enums.product.SearchProductConditionFieldEnum;
import cn.iocoder.mall.searchservice.rpc.product.SearchProductRpc;
@@ -19,6 +19,7 @@ import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO;
import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuSearchConditionRespVO;
import cn.iocoder.mall.shopweb.convert.product.ProductSpuConvert;
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;
@@ -39,8 +40,8 @@ public class ProductSpuManager {
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
private ProductCategoryRpc productCategoryRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
public PageResult pageProductSpu(ProductSpuPageReqVO pageReqVO) {
CommonResult> pageResult =
@@ -69,7 +70,7 @@ public class ProductSpuManager {
}
public ProductSpuDetailRespVO getProductSpuDetail(Integer id) {
- CommonResult getProductSpuDetailResult = productSpuRpc.getProductSpuDetail(id,
+ CommonResult getProductSpuDetailResult = productSpuFeign.getProductSpuDetail(id,
Arrays.asList(ProductSpuDetailFieldEnum.SKU.getField(), ProductSpuDetailFieldEnum.ATTR.getField()));
getProductSpuDetailResult.checkError();
return ProductSpuConvert.INSTANCE.convert(getProductSpuDetailResult.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 091693fd8..43d62a8d4 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
@@ -3,7 +3,7 @@ package cn.iocoder.mall.shopweb.service.promotion;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+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.dto.ProductRecommendListReqDTO;
@@ -13,6 +13,7 @@ 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;
@@ -30,8 +31,8 @@ public class ProductRecommendManager {
@DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}")
private ProductRecommendRpc productRecommendRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
- private ProductSpuRpc productSpuRpc;
+ @Autowired
+ private ProductSpuFeign productSpuFeign;
public Map> listProductRecommends() {
// 查询商品推荐列表
@@ -49,7 +50,7 @@ public class ProductRecommendManager {
}
private Map getProductSkuMap(List productRecommends) {
- CommonResult> listProductSpusResult = productSpuRpc.listProductSpus(
+ CommonResult> listProductSpusResult = productSpuFeign.listProductSpus(
CollectionUtils.convertSet(productRecommends, ProductRecommendRespDTO::getProductSpuId));
listProductSpusResult.checkError();
return CollectionUtils.convertMap(listProductSpusResult.getData(), ProductSpuRespDTO::getId);
From a01d66a318015a9a4f0a18a3bb35649dff3633d8 Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Thu, 7 Oct 2021 23:14:30 +0800
Subject: [PATCH 03/82] =?UTF-8?q?ProductAttr=E6=94=B9=E9=80=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ManagementWebApplication.java | 2 +-
.../product/ProductAttrController.http | 18 ++-
.../product/ProductAttrKeyManager.java | 27 ++--
.../rpc/attr/ProductAttrFeign.java | 94 +++++++++++++
.../rpc/attr/ProductAttrRpc.java | 84 ------------
.../controller/ProductAttrController.java | 128 ++++++++++++++++++
.../rpc/attr/ProductAttrRpcImpl.java | 70 ----------
.../PromotionServiceApplication.java | 2 +-
.../SearchServiceApplication.java | 2 +-
.../mall/shopweb/ShopWebApplication.java | 2 +-
10 files changed, 255 insertions(+), 174 deletions(-)
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrFeign.java
delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductAttrController.java
delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.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 0c15ca0e9..07f8d0139 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,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class ManagementWebApplication {
public static void main(String[] args) {
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.http
index c86c14a08..e946ab23d 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.http
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.http
@@ -1,7 +1,21 @@
### /product-attr/page 成功(全部)
-GET {{baseUrl}}/product-attr/key/page?pageNo=1&pageSize=10
+GET http://127.0.0.1:18083/management-api/product-attr/key/page?pageNo=1&pageSize=10
Content-Type: application/x-www-form-urlencoded
-Authorization: Bearer {{accessToken}}
+Authorization: Bearer yudaoyuanma
###
+POST http://127.0.0.1:18083/management-api/product-attr/key/create
+Content-Type: application/x-www-form-urlencoded
+Authorization: Bearer yudaoyuanma
+
+name=桶&status=1
+
+###
+POST http://127.0.0.1:18083/management-api/product-attr/value/create
+Content-Type: application/x-www-form-urlencoded
+Authorization: Bearer yudaoyuanma
+
+attrKeyId=12&name=大桶&status=1
+
+###
\ No newline at end of file
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java
index cfa5ec083..26590ba83 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java
@@ -4,10 +4,10 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.product.vo.attr.*;
import cn.iocoder.mall.managementweb.convert.product.ProductAttrConvert;
-import cn.iocoder.mall.productservice.rpc.attr.ProductAttrRpc;
+import cn.iocoder.mall.productservice.rpc.attr.ProductAttrFeign;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrValueRespDTO;
-import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -18,9 +18,8 @@ import java.util.List;
@Service
public class ProductAttrKeyManager {
- @DubboReference(version = "${dubbo.consumer.ProductAttrRpc.version}")
- private ProductAttrRpc productAttrKeyRpc;
-
+ @Autowired
+ private ProductAttrFeign productAttrFeign;
/**
* 创建商品规格键
*
@@ -28,7 +27,7 @@ public class ProductAttrKeyManager {
* @return 商品规格键
*/
public Integer createProductAttrKey(ProductAttrKeyCreateReqVO createVO) {
- CommonResult createProductAttrKeyResult = productAttrKeyRpc.createProductAttrKey(
+ CommonResult createProductAttrKeyResult = productAttrFeign.createProductAttrKey(
ProductAttrConvert.INSTANCE.convert(createVO));
createProductAttrKeyResult.checkError();
return createProductAttrKeyResult.getData();
@@ -40,7 +39,7 @@ public class ProductAttrKeyManager {
* @param updateVO 更新商品规格键 VO
*/
public void updateProductAttrKey(ProductAttrKeyUpdateReqVO updateVO) {
- CommonResult updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey(
+ CommonResult updateProductAttrKeyResult = productAttrFeign.updateProductAttrKey(
ProductAttrConvert.INSTANCE.convert(updateVO));
updateProductAttrKeyResult.checkError();
}
@@ -52,7 +51,7 @@ public class ProductAttrKeyManager {
* @return 商品规格键
*/
public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) {
- CommonResult getProductAttrKeyResult = productAttrKeyRpc.getProductAttrKey(productAttrKeyId);
+ CommonResult getProductAttrKeyResult = productAttrFeign.getProductAttrKey(productAttrKeyId);
getProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convert(getProductAttrKeyResult.getData());
}
@@ -64,7 +63,7 @@ public class ProductAttrKeyManager {
* @return 商品规格键列表
*/
public List listProductAttrKeys(List productAttrKeyIds) {
- CommonResult> listProductAttrKeyResult = productAttrKeyRpc.listProductAttrKeys(productAttrKeyIds);
+ CommonResult> listProductAttrKeyResult = productAttrFeign.listProductAttrKeys(productAttrKeyIds);
listProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convertList(listProductAttrKeyResult.getData());
}
@@ -76,7 +75,7 @@ public class ProductAttrKeyManager {
* @return 商品规格键分页结果
*/
public PageResult pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) {
- CommonResult> pageProductAttrKeyResult = productAttrKeyRpc.pageProductAttrKey(
+ CommonResult> pageProductAttrKeyResult = productAttrFeign.pageProductAttrKey(
ProductAttrConvert.INSTANCE.convert(pageVO));
pageProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData());
@@ -89,7 +88,7 @@ public class ProductAttrKeyManager {
* @return 商品规格值
*/
public Integer createProductAttrValue(ProductAttrValueCreateReqVO createVO) {
- CommonResult createProductAttrValueResult = productAttrKeyRpc.createProductAttrValue(
+ CommonResult createProductAttrValueResult = productAttrFeign.createProductAttrValue(
ProductAttrConvert.INSTANCE.convert(createVO));
createProductAttrValueResult.checkError();
return createProductAttrValueResult.getData();
@@ -101,7 +100,7 @@ public class ProductAttrKeyManager {
* @param updateVO 更新商品规格值 VO
*/
public void updateProductAttrValue(ProductAttrValueUpdateReqVO updateVO) {
- CommonResult updateProductAttrValueResult = productAttrKeyRpc.updateProductAttrValue(
+ CommonResult updateProductAttrValueResult = productAttrFeign.updateProductAttrValue(
ProductAttrConvert.INSTANCE.convert(updateVO));
updateProductAttrValueResult.checkError();
}
@@ -113,7 +112,7 @@ public class ProductAttrKeyManager {
* @return 商品规格值
*/
public ProductAttrValueRespVO getProductAttrValue(Integer productAttrValueId) {
- CommonResult getProductAttrValueResult = productAttrKeyRpc.getProductAttrValue(productAttrValueId);
+ CommonResult getProductAttrValueResult = productAttrFeign.getProductAttrValue(productAttrValueId);
getProductAttrValueResult.checkError();
return ProductAttrConvert.INSTANCE.convert(getProductAttrValueResult.getData());
}
@@ -125,7 +124,7 @@ public class ProductAttrKeyManager {
* @return 商品规格值列表
*/
public List listProductAttrValues(ProductAttrValueListQueryReqVO queryReqVO) {
- CommonResult> listProductAttrValueResult = productAttrKeyRpc.listProductAttrValues(
+ CommonResult> listProductAttrValueResult = productAttrFeign.listProductAttrValues(
ProductAttrConvert.INSTANCE.convert(queryReqVO));
listProductAttrValueResult.checkError();
return ProductAttrConvert.INSTANCE.convertList02(listProductAttrValueResult.getData());
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrFeign.java
new file mode 100644
index 000000000..0360aa6e3
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrFeign.java
@@ -0,0 +1,94 @@
+package cn.iocoder.mall.productservice.rpc.attr;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.common.framework.vo.PageResult;
+import cn.iocoder.mall.productservice.rpc.attr.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;
+
+/**
+ * 商品规格 Rpc 接口
+ */
+@FeignClient(value = "product-service")
+public interface ProductAttrFeign {
+
+ /**
+ * 创建商品规格键
+ *
+ * @param createDTO 创建商品规格键 DTO
+ * @return 商品规格键编号
+ */
+ @PostMapping(value = "/product/attr/createProductAttrKey")
+ CommonResult createProductAttrKey(@RequestBody ProductAttrKeyCreateReqDTO createDTO);
+
+ /**
+ * 更新商品规格键
+ *
+ * @param updateDTO 更新商品规格键 DTO
+ */
+ @PostMapping(value = "/product/attr/updateProductAttrKey")
+ CommonResult updateProductAttrKey(@RequestBody ProductAttrKeyUpdateReqDTO updateDTO);
+
+ /**
+ * 获得商品规格键
+ *
+ * @param productAttrKeyId 商品规格键编号
+ * @return 商品规格键
+ */
+ @GetMapping("/product/attr/getProductAttrKey")
+ CommonResult getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId);
+
+ /**
+ * 获得商品规格键列表
+ *
+ * @param productAttrKeyIds 商品规格键编号列表
+ * @return 商品规格键列表
+ */
+ @GetMapping("/product/attr/listProductAttrKeys")
+ CommonResult> listProductAttrKeys(@RequestParam("productAttrKeyIds") List productAttrKeyIds);
+
+ /**
+ * 获得商品规格键分页
+ *
+ * @param pageDTO 商品规格键分页查询
+ * @return 商品规格键分页结果
+ */
+ @PostMapping("/product/attr/pageProductAttrKey")
+ CommonResult> pageProductAttrKey(@RequestBody ProductAttrKeyPageReqDTO pageDTO);
+
+ /**
+ * 创建商品规格值
+ *
+ * @param createDTO 创建商品规格值 DTO
+ * @return 商品规格值编号
+ */
+ @PostMapping("/product/attr/createProductAttrValue")
+ CommonResult createProductAttrValue(@RequestBody ProductAttrValueCreateReqDTO createDTO);
+
+
+ /**
+ * 更新商品规格值
+ *
+ * @param updateDTO 更新商品规格值 DTO
+ */
+ @PostMapping("/product/attr/updateProductAttrValue")
+ CommonResult updateProductAttrValue(@RequestBody ProductAttrValueUpdateReqDTO updateDTO);
+
+ /**
+ * 获得商品规格值
+ *
+ * @param productAttrValueId 商品规格值编号
+ * @return 商品规格值
+ */
+ @GetMapping("/product/attr/getProductAttrValue")
+ CommonResult getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId);
+
+ @PostMapping("/product/attr/listProductAttrValues")
+ CommonResult> listProductAttrValues(@RequestBody ProductAttrValueListQueryReqDTO queryDTO);
+
+}
\ No newline at end of file
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java
deleted file mode 100644
index b36697489..000000000
--- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.attr;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.productservice.rpc.attr.dto.*;
-
-import java.util.List;
-
-/**
- * 商品规格 Rpc 接口
- */
-public interface ProductAttrRpc {
-
- /**
- * 创建商品规格键
- *
- * @param createDTO 创建商品规格键 DTO
- * @return 商品规格键编号
- */
- CommonResult createProductAttrKey(ProductAttrKeyCreateReqDTO createDTO);
-
- /**
- * 更新商品规格键
- *
- * @param updateDTO 更新商品规格键 DTO
- */
- CommonResult updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO);
-
- /**
- * 获得商品规格键
- *
- * @param productAttrKeyId 商品规格键编号
- * @return 商品规格键
- */
- CommonResult getProductAttrKey(Integer productAttrKeyId);
-
- /**
- * 获得商品规格键列表
- *
- * @param productAttrKeyIds 商品规格键编号列表
- * @return 商品规格键列表
- */
- CommonResult> listProductAttrKeys(List productAttrKeyIds);
-
- /**
- * 获得商品规格键分页
- *
- * @param pageDTO 商品规格键分页查询
- * @return 商品规格键分页结果
- */
- CommonResult> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO);
-
- /**
- * 创建商品规格值
- *
- * @param createDTO 创建商品规格值 DTO
- * @return 商品规格值编号
- */
- CommonResult createProductAttrValue(ProductAttrValueCreateReqDTO createDTO);
-
- /**
- * 更新商品规格值
- *
- * @param updateDTO 更新商品规格值 DTO
- */
- CommonResult updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO);
-
- /**
- * 获得商品规格值
- *
- * @param productAttrValueId 商品规格值编号
- * @return 商品规格值
- */
- CommonResult getProductAttrValue(Integer productAttrValueId);
-
- /**
- * 获得商品规格值列表
- *
- * @param queryDTO 商品规格值的列表查询条件 DTO
- * @return 商品规格值列表
- */
- CommonResult> listProductAttrValues(ProductAttrValueListQueryReqDTO queryDTO);
-
-}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductAttrController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductAttrController.java
new file mode 100644
index 000000000..26904d4e7
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductAttrController.java
@@ -0,0 +1,128 @@
+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.attr.ProductAttrManager;
+import cn.iocoder.mall.productservice.rpc.attr.dto.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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;
+
+@RestController
+@RequestMapping("/product/attr")
+@Api("商品属性")
+public class ProductAttrController {
+ @Autowired
+ private ProductAttrManager productAttrManager;
+
+ @PostMapping("/createProductAttrKey")
+ @ApiOperation("创建商品规格键")
+ CommonResult createProductAttrKey(@RequestBody ProductAttrKeyCreateReqDTO createDTO){
+ return success(productAttrManager.createProductAttrKey(createDTO));
+ }
+
+ /**
+ * 更新商品规格键
+ *
+ * @param updateDTO 更新商品规格键 DTO
+ */
+ @PostMapping("/updateProductAttrKey")
+ @ApiOperation("更新商品规格键")
+ CommonResult updateProductAttrKey(@RequestBody ProductAttrKeyUpdateReqDTO updateDTO){
+ productAttrManager.updateProductAttrKey(updateDTO);
+ return success(true);
+ }
+
+ /**
+ * 获得商品规格键
+ *
+ * @param productAttrKeyId 商品规格键编号
+ * @return 商品规格键
+ */
+ @GetMapping("/getProductAttrKey")
+ @ApiOperation("获得商品规格键")
+ CommonResult getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId){
+ return success(productAttrManager.getProductAttrKey(productAttrKeyId));
+ }
+
+
+ /**
+ * 获得商品规格键列表
+ *
+ * @param productAttrKeyIds 商品规格键编号列表
+ * @return 商品规格键列表
+ */
+ @GetMapping("/listProductAttrKeys")
+ @ApiOperation("获得商品规格键列表")
+ CommonResult> listProductAttrKeys(@RequestParam("productAttrKeyIds") List productAttrKeyIds){
+ return success(productAttrManager.listProductAttrKeys(productAttrKeyIds));
+ }
+
+ /**
+ * 获得商品规格键分页
+ *
+ * @param pageDTO 商品规格键分页查询
+ * @return 商品规格键分页结果
+ */
+ @PostMapping("/pageProductAttrKey")
+ @ApiOperation("获得商品规格键分页")
+ CommonResult> pageProductAttrKey(@RequestBody ProductAttrKeyPageReqDTO pageDTO){
+ return success(productAttrManager.pageProductAttrKey(pageDTO));
+ }
+
+ /**
+ * 创建商品规格值
+ *
+ * @param createDTO 创建商品规格值 DTO
+ * @return 商品规格值编号
+ */
+ @PostMapping("/createProductAttrValue")
+ @ApiOperation("创建商品规格值")
+ CommonResult createProductAttrValue(@RequestBody ProductAttrValueCreateReqDTO createDTO){
+ return success(productAttrManager.createProductAttrValue(createDTO));
+ }
+
+
+
+ /**
+ * 更新商品规格值
+ *
+ * @param updateDTO 更新商品规格值 DTO
+ */
+ @PostMapping("/updateProductAttrValue")
+ @ApiOperation("更新商品规格值")
+ CommonResult updateProductAttrValue(@RequestBody ProductAttrValueUpdateReqDTO updateDTO){
+ productAttrManager.updateProductAttrValue(updateDTO);
+ return success(true);
+ }
+
+ /**
+ * 获得商品规格值
+ *
+ * @param productAttrValueId 商品规格值编号
+ * @return 商品规格值
+ */
+ @GetMapping("/getProductAttrValue")
+ @ApiOperation("获得商品规格值")
+ CommonResult getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId){
+ return success(productAttrManager.getProductAttrValue(productAttrValueId));
+ }
+
+ /**
+ * 获得商品规格值列表
+ *
+ * @param queryDTO 商品规格值的列表查询条件 DTO
+ * @return 商品规格值列表
+ */
+ @PostMapping("/listProductAttrValues")
+ @ApiOperation("获得商品规格值列表")
+ CommonResult> listProductAttrValues(@RequestBody ProductAttrValueListQueryReqDTO queryDTO){
+ return success(productAttrManager.listProductAttrValues(queryDTO));
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java
deleted file mode 100644
index 889e261de..000000000
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.attr;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.productservice.manager.attr.ProductAttrManager;
-import cn.iocoder.mall.productservice.rpc.attr.dto.*;
-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 ProductAttrRpcImpl implements ProductAttrRpc {
-
- @Autowired
- private ProductAttrManager productAttrManager;
-
- @Override
- public CommonResult createProductAttrKey(ProductAttrKeyCreateReqDTO createDTO) {
- return success(productAttrManager.createProductAttrKey(createDTO));
- }
-
- @Override
- public CommonResult updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO) {
- productAttrManager.updateProductAttrKey(updateDTO);
- return success(true);
- }
-
- @Override
- public CommonResult getProductAttrKey(Integer productAttrKeyId) {
- return success(productAttrManager.getProductAttrKey(productAttrKeyId));
- }
-
- @Override
- public CommonResult> listProductAttrKeys(List productAttrKeyIds) {
- return success(productAttrManager.listProductAttrKeys(productAttrKeyIds));
- }
-
- @Override
- public CommonResult> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO) {
- return success(productAttrManager.pageProductAttrKey(pageDTO));
- }
-
- @Override
- public CommonResult createProductAttrValue(ProductAttrValueCreateReqDTO createDTO) {
- return success(productAttrManager.createProductAttrValue(createDTO));
- }
-
- @Override
- public CommonResult updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO) {
- productAttrManager.updateProductAttrValue(updateDTO);
- return success(true);
- }
-
- @Override
- public CommonResult getProductAttrValue(Integer productAttrValueId) {
- return success(productAttrManager.getProductAttrValue(productAttrValueId));
- }
-
- @Override
- public CommonResult> listProductAttrValues(ProductAttrValueListQueryReqDTO queryDTO) {
- return success(productAttrManager.listProductAttrValues(queryDTO));
- }
-
-}
diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
index 06143b6c9..0a460a932 100644
--- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
+++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
@@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class PromotionServiceApplication {
public static void main(String[] args) {
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
index a0a162ac1..fb9a89867 100644
--- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
@@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class SearchServiceApplication {
public static void main(String[] args) {
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 ca0a38146..ec1fbd429 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
@@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class ShopWebApplication {
public static void main(String[] args) {
From b5b102d13f618cd72045d93067035bb4df373131 Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Thu, 7 Oct 2021 23:30:17 +0800
Subject: [PATCH 04/82] =?UTF-8?q?ProductBrand=E6=94=B9=E9=80=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../product/ProductBrandController.http | 20 ++++
.../manager/product/ProductBrandManager.java | 21 ++--
.../rpc/brand/ProductBrandFeign.java | 69 +++++++++++++
.../controller/ProductBrandController.java | 98 +++++++++++++++++++
4 files changed, 197 insertions(+), 11 deletions(-)
create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductBrandController.http
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandFeign.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductBrandController.java
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductBrandController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductBrandController.http
new file mode 100644
index 000000000..1d862b54c
--- /dev/null
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductBrandController.http
@@ -0,0 +1,20 @@
+### /product-attr/page 成功(全部)
+GET http://127.0.0.1:18083/management-api/product-attr/key/page?pageNo=1&pageSize=10
+Content-Type: application/x-www-form-urlencoded
+Authorization: Bearer yudaoyuanma
+
+###
+
+POST http://127.0.0.1:18083/management-api/product-brand/create
+Content-Type: application/x-www-form-urlencoded
+Authorization: Bearer yudaoyuanma
+
+name=光明牌&description=光明牌电灯泡&status=1
+
+###
+GET http://127.0.0.1:18083/management-api/product-brand/get?productBrandId=3
+Content-Type: application/x-www-form-urlencoded
+Authorization: Bearer yudaoyuanma
+
+
+###
\ No newline at end of file
diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductBrandManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductBrandManager.java
index a704dece4..bed770850 100644
--- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductBrandManager.java
+++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductBrandManager.java
@@ -7,9 +7,9 @@ import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandPag
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO;
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.product.ProductBrandConvert;
-import cn.iocoder.mall.productservice.rpc.brand.ProductBrandRpc;
+import cn.iocoder.mall.productservice.rpc.brand.ProductBrandFeign;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
-import org.apache.dubbo.config.annotation.Reference;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -20,9 +20,8 @@ import java.util.List;
@Service
public class ProductBrandManager {
- @Reference(version = "${dubbo.consumer.ProductBrandRpc.version}")
- private ProductBrandRpc productBrandRpc;
-
+ @Autowired
+ ProductBrandFeign productBrandFeign;
/**
* 创建商品品牌
*
@@ -30,7 +29,7 @@ public class ProductBrandManager {
* @return 商品品牌
*/
public Integer createProductBrand(ProductBrandCreateReqVO createVO) {
- CommonResult createProductBrandResult = productBrandRpc.createProductBrand(ProductBrandConvert.INSTANCE.convert(createVO));
+ CommonResult createProductBrandResult = productBrandFeign.createProductBrand(ProductBrandConvert.INSTANCE.convert(createVO));
createProductBrandResult.checkError();
return createProductBrandResult.getData();
}
@@ -41,7 +40,7 @@ public class ProductBrandManager {
* @param updateVO 更新商品品牌 VO
*/
public void updateProductBrand(ProductBrandUpdateReqVO updateVO) {
- CommonResult updateProductBrandResult = productBrandRpc.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateVO));
+ CommonResult updateProductBrandResult = productBrandFeign.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateVO));
updateProductBrandResult.checkError();
}
@@ -51,7 +50,7 @@ public class ProductBrandManager {
* @param productBrandId 商品品牌编号
*/
public void deleteProductBrand(Integer productBrandId) {
- CommonResult deleteProductBrandResult = productBrandRpc.deleteProductBrand(productBrandId);
+ CommonResult deleteProductBrandResult = productBrandFeign.deleteProductBrand(productBrandId);
deleteProductBrandResult.checkError();
}
@@ -62,7 +61,7 @@ public class ProductBrandManager {
* @return 商品品牌
*/
public ProductBrandRespVO getProductBrand(Integer productBrandId) {
- CommonResult getProductBrandResult = productBrandRpc.getProductBrand(productBrandId);
+ CommonResult getProductBrandResult = productBrandFeign.getProductBrand(productBrandId);
getProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convert(getProductBrandResult.getData());
}
@@ -74,7 +73,7 @@ public class ProductBrandManager {
* @return 商品品牌列表
*/
public List listProductBrands(List productBrandIds) {
- CommonResult> listProductBrandResult = productBrandRpc.listProductBrands(productBrandIds);
+ CommonResult> listProductBrandResult = productBrandFeign.listProductBrands(productBrandIds);
listProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convertList(listProductBrandResult.getData());
}
@@ -86,7 +85,7 @@ public class ProductBrandManager {
* @return 商品品牌分页结果
*/
public PageResult pageProductBrand(ProductBrandPageReqVO pageVO) {
- CommonResult> pageProductBrandResult = productBrandRpc.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageVO));
+ CommonResult> pageProductBrandResult = productBrandFeign.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageVO));
pageProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convertPage(pageProductBrandResult.getData());
}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandFeign.java
new file mode 100644
index 000000000..69b279de1
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/brand/ProductBrandFeign.java
@@ -0,0 +1,69 @@
+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 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;
+
+@FeignClient(value = "product-service")
+public interface ProductBrandFeign {
+ /**
+ * 创建商品品牌
+ *
+ * @param createDTO 创建商品品牌 DTO
+ * @return 商品品牌编号
+ */
+ @PostMapping("/product/brand/createProductBrand")
+ CommonResult createProductBrand(@RequestBody ProductBrandCreateReqDTO createDTO);
+
+ /**
+ * 更新商品品牌
+ *
+ * @param updateDTO 更新商品品牌 DTO
+ */
+ @PostMapping("/product/brand/updateProductBrand")
+ CommonResult updateProductBrand(@RequestBody ProductBrandUpdateReqDTO updateDTO);
+
+ /**
+ * 删除商品品牌
+ *
+ * @param productBrandId 商品品牌编号
+ */
+ @GetMapping("/product/brand/deleteProductBrand")
+ CommonResult deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId);
+ /**
+ * 获得商品品牌
+ *
+ * @param productBrandId 商品品牌编号
+ * @return 商品品牌
+ */
+ @GetMapping("/product/brand/getProductBrand")
+ CommonResult getProductBrand(@RequestParam("productBrandId")Integer productBrandId);
+ /**
+ * 获得商品品牌列表
+ *
+ * @param productBrandIds 商品品牌编号列表
+ * @return 商品品牌列表
+ */
+ @GetMapping("/product/brand/listProductBrands")
+ CommonResult> listProductBrands(@RequestParam("productBrandIds") List productBrandIds);
+
+ /**
+ * 获得商品品牌分页
+ *
+ * @param pageDTO 商品品牌分页查询
+ * @return 商品品牌分页结果
+ */
+ @PostMapping("/product/brand/pageProductBrand")
+ CommonResult> pageProductBrand(@RequestBody ProductBrandPageReqDTO pageDTO);
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductBrandController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductBrandController.java
new file mode 100644
index 000000000..1b568aacc
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductBrandController.java
@@ -0,0 +1,98 @@
+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.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 io.swagger.annotations.Api;
+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;
+
+/**
+ * Title:
+ * Description:
+ *
+ * @author zhuyang
+ * @version 1.0 2021/10/7
+ */
+@RestController
+@RequestMapping("/product/brand")
+@Api("商品品牌")
+public class ProductBrandController {
+ @Autowired
+ private ProductBrandManager productBrandManager;
+
+ /**
+ * 创建商品品牌
+ *
+ * @param createDTO 创建商品品牌 DTO
+ * @return 商品品牌编号
+ */
+ @PostMapping("createProductBrand")
+ CommonResult createProductBrand(@RequestBody ProductBrandCreateReqDTO createDTO){
+ return success(productBrandManager.createProductBrand(createDTO));
+ }
+
+ /**
+ * 更新商品品牌
+ *
+ * @param updateDTO 更新商品品牌 DTO
+ */
+ @PostMapping("updateProductBrand")
+ CommonResult updateProductBrand(@RequestBody ProductBrandUpdateReqDTO updateDTO){
+ productBrandManager.updateProductBrand(updateDTO);
+ return success(true);
+ }
+
+ /**
+ * 删除商品品牌
+ *
+ * @param productBrandId 商品品牌编号
+ */
+ @GetMapping("deleteProductBrand")
+ CommonResult deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId){
+ productBrandManager.deleteProductBrand(productBrandId);
+ return success(true);
+ }
+
+ /**
+ * 获得商品品牌
+ *
+ * @param productBrandId 商品品牌编号
+ * @return 商品品牌
+ */
+ @GetMapping("getProductBrand")
+ CommonResult getProductBrand(@RequestParam("productBrandId")Integer productBrandId){
+ return success(productBrandManager.getProductBrand(productBrandId));
+ }
+
+ /**
+ * 获得商品品牌列表
+ *
+ * @param productBrandIds 商品品牌编号列表
+ * @return 商品品牌列表
+ */
+ @GetMapping("listProductBrands")
+ CommonResult> listProductBrands(@RequestParam("productBrandIds") List productBrandIds){
+ return success(productBrandManager.listProductBrands(productBrandIds));
+ }
+
+ /**
+ * 获得商品品牌分页
+ *
+ * @param pageDTO 商品品牌分页查询
+ * @return 商品品牌分页结果
+ */
+ @PostMapping("pageProductBrand")
+ CommonResult> pageProductBrand(@RequestBody ProductBrandPageReqDTO pageDTO){
+ return success(productBrandManager.pageProductBrand(pageDTO));
+ }
+
+}
From 50d8aac20f762ef2d7b038243a8fd4098edb3201 Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Thu, 7 Oct 2021 23:45:17 +0800
Subject: [PATCH 05/82] =?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()));
}
From 53a33e4999dfc14921882a72ebc70c0441652a23 Mon Sep 17 00:00:00 2001
From: zhuyang <1qazxsw2>
Date: Thu, 7 Oct 2021 23:55:34 +0800
Subject: [PATCH 06/82] =?UTF-8?q?ProductSku=E6=94=B9=E9=80=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rpc/sku/ProductSkuFeign.java | 27 +++++++++++
.../productservice/rpc/sku/ProductSkuRpc.java | 30 ------------
.../controller/ProductSkuController.java | 47 +++++++++++++++++++
.../rpc/sku/ProductSkuRpcImpl.java | 33 -------------
.../manager/price/PriceManager.java | 9 ++--
.../manager/product/SearchProductManager.java | 9 ++--
.../product/ProductSkuController.http | 2 +-
.../shopweb/service/trade/CartManager.java | 14 +++---
.../service/trade/TradeOrderService.java | 9 ++--
.../tradeservice/TradeServiceApplication.java | 4 ++
.../client/product/ProductSkuClient.java | 11 ++---
.../service/cart/CartManager.java | 12 ++---
12 files changed, 110 insertions(+), 97 deletions(-)
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java
delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java
delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java
new file mode 100644
index 000000000..94b077eac
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java
@@ -0,0 +1,27 @@
+package cn.iocoder.mall.productservice.rpc.sku;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+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;
+
+@FeignClient(value = "product-service")
+public interface ProductSkuFeign {
+ @GetMapping("/product/sku/getProductSku")
+ CommonResult getProductSku(@RequestParam("productSkuId") Integer productSkuId);
+
+ /**
+ * 获得商品 SKU 列表
+ *
+ * @param queryReqDTO 商品 SKU 列表的查询请求 DTO
+ * @return 商品 SKU 列表
+ */
+ @PostMapping("/product/sku/listProductSkus")
+ CommonResult> listProductSkus(@RequestBody ProductSkuListQueryReqDTO queryReqDTO);
+}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java
deleted file mode 100644
index 89b20d488..000000000
--- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.sku;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
-import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
-
-import java.util.List;
-
-/**
- * 商品 SKU Rpc 接口
- */
-public interface ProductSkuRpc {
-
- /**
- * 获得商品 SKU
- *
- * @param productSkuId 商品 SKU 编号
- * @return 商品 SKU
- */
- CommonResult getProductSku(Integer productSkuId);
-
- /**
- * 获得商品 SKU 列表
- *
- * @param queryReqDTO 商品 SKU 列表的查询请求 DTO
- * @return 商品 SKU 列表
- */
- CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO);
-
-}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java
new file mode 100644
index 000000000..5e3e83782
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java
@@ -0,0 +1,47 @@
+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.attr.ProductAttrManager;
+import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager;
+import cn.iocoder.mall.productservice.rpc.attr.dto.*;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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;
+
+@RestController
+@RequestMapping("/product/sku")
+@Api("商品sku")
+public class ProductSkuController {
+ @Autowired
+ private ProductSkuManager productSkuManager;
+ /**
+ * 获得商品 SKU
+ *
+ * @param productSkuId 商品 SKU 编号
+ * @return 商品 SKU
+ */
+ @GetMapping("getProductSku")
+ CommonResult getProductSku(@RequestParam("productSkuId") Integer productSkuId){
+ return success(productSkuManager.getProductSku(productSkuId));
+ }
+
+ /**
+ * 获得商品 SKU 列表
+ *
+ * @param queryReqDTO 商品 SKU 列表的查询请求 DTO
+ * @return 商品 SKU 列表
+ */
+ @PostMapping("listProductSkus")
+ CommonResult> listProductSkus(@RequestBody ProductSkuListQueryReqDTO queryReqDTO){
+ return success(productSkuManager.listProductSkus(queryReqDTO));
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java
deleted file mode 100644
index 0528b5d63..000000000
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.iocoder.mall.productservice.rpc.sku;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager;
-import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
-import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
-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;
-
-/**
- * 商品 SKU Rpc 实现类
- */
-@DubboService
-public class ProductSkuRpcImpl implements ProductSkuRpc {
-
- @Autowired
- private ProductSkuManager productSkuManager;
-
- @Override
- public CommonResult getProductSku(Integer productSkuId) {
- return success(productSkuManager.getProductSku(productSkuId));
- }
-
- @Override
- public CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) {
- return success(productSkuManager.listProductSkus(queryReqDTO));
- }
-
-}
diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
index 142851957..00b259777 100644
--- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
+++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
@@ -3,7 +3,7 @@ package cn.iocoder.mall.promotionservice.manager.price;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
+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.productservice.rpc.spu.ProductSpuFeign;
@@ -21,7 +21,6 @@ import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.promotionservice.service.activity.PromotionActivityService;
import cn.iocoder.mall.promotionservice.service.coupon.CouponCardService;
import cn.iocoder.mall.promotionservice.service.coupon.CouponTemplateService;
-import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@@ -36,8 +35,8 @@ import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.*;
@Validated
public class PriceManager {
- @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
- private ProductSkuRpc productSkuRpc;
+ @Autowired
+ private ProductSkuFeign productSkuFeign;
@Autowired
private ProductSpuFeign productSpuFeign;
@@ -53,7 +52,7 @@ public class PriceManager {
// 校验商品都存在
Map calcProductItemDTOMap = CollectionUtils.convertMap(
calcReqDTO.getItems(), PriceProductCalcReqDTO.Item::getSkuId);
- CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(
+ CommonResult> listProductSkusResult = productSkuFeign.listProductSkus(
new ProductSkuListQueryReqDTO().setProductSkuIds(calcProductItemDTOMap.keySet()));
listProductSkusResult.checkError();
if (calcReqDTO.getItems().size() != listProductSkusResult.getData().size()) {
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 cc7ee0799..ec7e2461a 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
@@ -5,7 +5,7 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
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.ProductSkuFeign;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
@@ -20,7 +20,6 @@ import cn.iocoder.mall.searchservice.service.product.bo.SearchProductBO;
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductConditionBO;
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO;
import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,9 +32,9 @@ public class SearchProductManager {
private static final Integer REBUILD_FETCH_PER_SIZE = 100;
- @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
- private ProductSkuRpc productSkuRpc;
+ @Autowired
+ private ProductSkuFeign productSkuFeign;
@Autowired
private ProductCategoryFeign productCategoryFeign;
@Autowired
@@ -102,7 +101,7 @@ public class SearchProductManager {
}
// 获得商品 SKU
CommonResult> listProductSkusResult =
- productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO().setProductSpuId(id));
+ productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO().setProductSpuId(id));
listProductSkusResult.checkError();
if (CollectionUtils.isEmpty(listProductSkusResult.getData())) {
log.error("[saveProduct][商品 SPU({}) 的 SKU 不存在]", id);
diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http
index 32329b3ac..d304b6911 100644
--- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http
+++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http
@@ -1,5 +1,5 @@
### /product-spu/page 计算商品 SKU 价格
-GET {{shop-api-base-url}}/product-sku/cal-price?id=33
+GET http://127.0.0.1:18084/shop-api/product-sku/cal-price?id=33
Content-Type: application/x-www-form-urlencoded
###
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 fb5836f46..74eb228c0 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
@@ -2,10 +2,8 @@ package cn.iocoder.mall.shopweb.service.trade;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc;
-import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
-import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
+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;
@@ -16,7 +14,10 @@ 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.CartRpc;
+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;
import java.util.*;
@@ -34,8 +35,9 @@ public class CartManager {
private PriceRpc priceRpc;
@DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}")
private PromotionActivityRpc promotionActivityRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
- private ProductSkuRpc productSkuRpc;
+
+ @Autowired
+ private ProductSkuFeign productSkuFeign;
/**
* 添加商品到购物车
@@ -158,7 +160,7 @@ public class CartManager {
}
private Map getProductSkuMap(List itemRespDTOs) {
- CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO()
+ CommonResult> listProductSkusResult = productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO()
.setProductSkuIds(CollectionUtils.convertSet(itemRespDTOs, CartItemRespDTO::getSkuId))
.setFields(Arrays.asList(ProductSkuDetailFieldEnum.SPU.getField(), ProductSkuDetailFieldEnum.ATTR.getField())));
listProductSkusResult.checkError();
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 e0c6d2fe5..42fadd4bd 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
@@ -6,7 +6,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.sku.ProductSkuDetailFieldEnum;
-import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
+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;
@@ -55,10 +55,11 @@ public class TradeOrderService {
private PromotionActivityRpc promotionActivityRpc;
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
private CartRpc cartRpc;
- @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
- private ProductSkuRpc productSkuRpc;
@DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}")
private CouponCardRpc couponCardRpc;
+
+ @Autowired
+ private ProductSkuFeign productSkuFeign;
@Autowired
private TradeOrderClient tradeOrderClient;
@@ -128,7 +129,7 @@ public class TradeOrderService {
private Map checkProductSkus(Map skuMap) {
// 获得商品 SKU 列表
- CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO()
+ CommonResult> listProductSkusResult = productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO()
.setProductSkuIds(skuMap.keySet())
.setFields(Arrays.asList(ProductSkuDetailFieldEnum.SPU.getField(), ProductSkuDetailFieldEnum.ATTR.getField())));
listProductSkusResult.checkError();
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 8dc4f8733..c1fcbdbf7 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
@@ -2,8 +2,12 @@ package cn.iocoder.mall.tradeservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.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/product/ProductSkuClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java
index 88b2c9fe3..1645f365b 100644
--- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java
+++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java
@@ -2,10 +2,10 @@ package cn.iocoder.mall.tradeservice.client.product;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
+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 org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
@@ -15,15 +15,14 @@ import java.util.List;
@Service
public class ProductSkuClient {
-
- @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
- private ProductSkuRpc productSkuRpc;
+ @Autowired
+ private ProductSkuFeign productSkuFeign;
public List listProductSkus(Collection productSkuIds, String... fields) {
if (CollectionUtils.isEmpty(productSkuIds)) {
return Collections.emptyList();
}
- CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(
+ CommonResult