From d2e722377bbe9f0591342346f02ad061b465e748 Mon Sep 17 00:00:00 2001 From: yh <1844516659@qq.com> Date: Tue, 19 Jul 2022 18:54:46 +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=E8=B0=83=E7=94=A8service-driver?= =?UTF-8?q?-user=E5=AE=9E=E7=8E=B0=E5=8F=B8=E6=9C=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A5=E5=8F=8A=E6=96=B0=E5=A2=9E=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DriverUserController.java | 21 +++++++++++++++++++ .../remote/ServiceDriverUserClient.java | 4 ++++ .../apiboss/service/UserService.java | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) 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 index 2592c95..3aa9ae5 100644 --- a/api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java +++ b/api-boss/src/main/java/com/mashibing/apiboss/controller/DriverUserController.java @@ -3,8 +3,10 @@ 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.apache.commons.lang.StringUtils; 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; @@ -15,9 +17,28 @@ public class DriverUserController { @Autowired private UserService service; + /** + * 新增 司机 用户信息 + * @param driverUser + * @return + */ @PostMapping("/driver-user") public ResponseResult saveDriverUser(@RequestBody DriverUser driverUser){ + // 接口扩展 + if(driverUser.getId() != null && driverUser.getId() > 0){ + return service.updateDriverUser(driverUser); + } return service.saveDriverUser(driverUser); } + /** + * 修改 司机 用户信息 + * @param driverUser + * @return + */ + @PutMapping("/driver-user") + public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){ + return service.updateDriverUser(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 index be1e0ff..386d887 100644 --- a/api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java +++ b/api-boss/src/main/java/com/mashibing/apiboss/remote/ServiceDriverUserClient.java @@ -5,6 +5,7 @@ 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.PutMapping; import org.springframework.web.bind.annotation.RequestBody; @Service @@ -14,4 +15,7 @@ public interface ServiceDriverUserClient { @PostMapping("/user") public ResponseResult saveUser(@RequestBody DriverUser driverUser); + @PutMapping("/user") + public ResponseResult updateUser(@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 index c73b799..1f7b7b2 100644 --- a/api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java +++ b/api-boss/src/main/java/com/mashibing/apiboss/service/UserService.java @@ -13,8 +13,11 @@ public class UserService { private ServiceDriverUserClient client; public ResponseResult saveDriverUser(DriverUser driverUser){ - return client.saveUser(driverUser); } + public ResponseResult updateDriverUser(DriverUser driverUser){ + return client.updateUser(driverUser); + } + }