parent
870857edc6
commit
5ee65d6685
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.taxi</groupId>
|
||||
<artifactId>online-taxi-public</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>api-driver</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
package com.taxi.apidriver;
|
||||
|
||||
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 ApiDriverApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ApiDriverApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.taxi.apidriver.controller;
|
||||
|
||||
import com.internal.dto.DriverUser;
|
||||
import com.internal.dto.ResponseResult;
|
||||
import com.taxi.apidriver.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/users")
|
||||
public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
|
||||
return userService.addDriverUser(driverUser);
|
||||
}
|
||||
|
||||
@PutMapping("/user")
|
||||
public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){
|
||||
return userService.updateDriverUser(driverUser);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.taxi.apidriver.remote;
|
||||
|
||||
import com.internal.dto.DriverUser;
|
||||
import com.internal.dto.ResponseResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@FeignClient("service-driver-user")
|
||||
public interface ServiceDirverUserClient {
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/users")
|
||||
ResponseResult addDriverUser(@RequestBody DriverUser driverUser);
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT,value = "/user")
|
||||
ResponseResult updateDriverUser(@RequestBody DriverUser driverUser);
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.taxi.apidriver.service;
|
||||
|
||||
import com.internal.dto.DriverUser;
|
||||
import com.internal.dto.ResponseResult;
|
||||
import com.taxi.apidriver.remote.ServiceDirverUserClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Autowired
|
||||
private ServiceDirverUserClient serviceDirverUserClient;
|
||||
|
||||
public ResponseResult addDriverUser(DriverUser driverUser) {
|
||||
return serviceDirverUserClient.addDriverUser(driverUser);
|
||||
}
|
||||
|
||||
@PutMapping("/users")
|
||||
public ResponseResult updateDriverUser(DriverUser driverUser) {
|
||||
return serviceDirverUserClient.updateDriverUser(driverUser);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
server:
|
||||
port: 8088
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
|
||||
application:
|
||||
name: api-driver
|
@ -0,0 +1,11 @@
|
||||
server:
|
||||
port: 8088
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
|
||||
application:
|
||||
name: api-driver
|
Loading…
Reference in new issue