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