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); + } + +}