api-boss调用service-driver-user

main
topsun 2 years ago
parent 444c29b068
commit cb7eafd3ac

@ -22,6 +22,17 @@
<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>

@ -2,8 +2,10 @@ package com.taxi.aipboss;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class ApiBossApplication {
public static void main(String[] args) {
SpringApplication.run(ApiBossApplication.class);

@ -0,0 +1,21 @@
package com.taxi.aipboss.controller;
import com.internal.dto.DriverUser;
import com.internal.dto.ResponseResult;
import com.taxi.aipboss.service.DriverUserService;
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 DriverUserService driverUserService;
@PostMapping("/driver-user")
public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
return driverUserService.addDriverUser(driverUser);
}
}

@ -0,0 +1,15 @@
package com.taxi.aipboss.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 ServiceDriverUserClient {
@RequestMapping(method = RequestMethod.POST,value = "/users")
ResponseResult addDriverUser(@RequestBody DriverUser driverUser);
}

@ -0,0 +1,17 @@
package com.taxi.aipboss.service;
import com.internal.dto.DriverUser;
import com.internal.dto.ResponseResult;
import com.taxi.aipboss.remote.ServiceDriverUserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DriverUserService {
@Autowired
private ServiceDriverUserClient serviceDriverUserClient;
public ResponseResult addDriverUser(DriverUser driverUser){
return serviceDriverUserClient.addDriverUser(driverUser);
}
}
Loading…
Cancel
Save