From b35acd6040c9181cc97c3076202170a91a6a8ef5 Mon Sep 17 00:00:00 2001
From: yh <1844516659@qq.com>
Date: Tue, 19 Jul 2022 18:26:09 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A3=9E=E6=BB=B4=E5=87=BA=E8=A1=8C=E7=BD=91?=
=?UTF-8?q?=E7=BA=A6=E8=BD=A62022-api-boss=E9=80=9A=E8=BF=87feign=E8=BF=9C?=
=?UTF-8?q?=E7=A8=8B=E8=B0=83=E7=94=A8service-driver-user=E5=AE=9E?=
=?UTF-8?q?=E7=8E=B0=E5=8F=B8=E6=9C=BA=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api-boss/pom.xml | 9 ++++++++
.../mashibing/apiboss/ApiBossApplication.java | 4 ++++
.../controller/DriverUserController.java | 23 +++++++++++++++++++
.../remote/ServiceDriverUserClient.java | 17 ++++++++++++++
.../apiboss/service/UserService.java | 20 ++++++++++++++++
5 files changed, 73 insertions(+)
create mode 100644 api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java
create mode 100644 api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java
create mode 100644 api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java
diff --git a/api-boss/pom.xml b/api-boss/pom.xml
index f755ff5..f10d459 100644
--- a/api-boss/pom.xml
+++ b/api-boss/pom.xml
@@ -20,6 +20,15 @@
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
\ No newline at end of file
diff --git a/api-boss/src/main/java/com/mashibing/apiboss/ApiBossApplication.java b/api-boss/src/main/java/com/mashibing/apiboss/ApiBossApplication.java
index 0615eb5..a35e828 100644
--- a/api-boss/src/main/java/com/mashibing/apiboss/ApiBossApplication.java
+++ b/api-boss/src/main/java/com/mashibing/apiboss/ApiBossApplication.java
@@ -2,8 +2,12 @@ package com.mashibing.apiboss;
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 ApiBossApplication {
public static void main(String[] args) {
SpringApplication.run(ApiBossApplication.class);
diff --git a/api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java b/api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java
new file mode 100644
index 0000000..2592c95
--- /dev/null
+++ b/api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java
@@ -0,0 +1,23 @@
+package com.mashibing.apiboss.controller;
+
+import com.mashibing.apiboss.service.UserService;
+import com.mashibing.internalcommon.dto.DriverUser;
+import com.mashibing.internalcommon.dto.ResponseResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class DriverUserController {
+
+
+ @Autowired
+ private UserService service;
+
+ @PostMapping("/driver-user")
+ public ResponseResult saveDriverUser(@RequestBody DriverUser driverUser){
+ return service.saveDriverUser(driverUser);
+ }
+
+}
diff --git a/api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java b/api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java
new file mode 100644
index 0000000..be1e0ff
--- /dev/null
+++ b/api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java
@@ -0,0 +1,17 @@
+package com.mashibing.apiboss.remote;
+
+import com.mashibing.internalcommon.dto.DriverUser;
+import com.mashibing.internalcommon.dto.ResponseResult;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@Service
+@FeignClient("service-driver-user")
+public interface ServiceDriverUserClient {
+
+ @PostMapping("/user")
+ public ResponseResult saveUser(@RequestBody DriverUser driverUser);
+
+}
diff --git a/api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java b/api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java
new file mode 100644
index 0000000..c73b799
--- /dev/null
+++ b/api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java
@@ -0,0 +1,20 @@
+package com.mashibing.apiboss.service;
+
+import com.mashibing.apiboss.remote.ServiceDriverUserClient;
+import com.mashibing.internalcommon.dto.DriverUser;
+import com.mashibing.internalcommon.dto.ResponseResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserService {
+
+ @Autowired
+ private ServiceDriverUserClient client;
+
+ public ResponseResult saveDriverUser(DriverUser driverUser){
+
+ return client.saveUser(driverUser);
+ }
+
+}