|
|
|
@ -2,12 +2,11 @@ package com.taxi.servicedriveruser.controller;
|
|
|
|
|
|
|
|
|
|
import com.internal.dto.DriverUser;
|
|
|
|
|
import com.internal.dto.ResponseResult;
|
|
|
|
|
import com.internal.response.DriverUserExistsResponse;
|
|
|
|
|
import com.taxi.servicedriveruser.service.DriverUserService;
|
|
|
|
|
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;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@ -16,15 +15,46 @@ public class DriverUserController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private DriverUserService driverUserService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增司机
|
|
|
|
|
* @param driverUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/users")
|
|
|
|
|
public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
|
|
|
|
|
|
|
|
|
|
return driverUserService.addDriverUser(driverUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改司机信息
|
|
|
|
|
* @param driverUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/user")
|
|
|
|
|
public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){
|
|
|
|
|
return driverUserService.updateDriverUser(driverUser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询司机
|
|
|
|
|
* @param driverPhone
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/check-driver/{driverPhone}")
|
|
|
|
|
public ResponseResult getUser(@PathVariable("driverPhone") String driverPhone){
|
|
|
|
|
DriverUser driverUserDB = driverUserService.getUser(driverPhone).getData();
|
|
|
|
|
DriverUserExistsResponse driverUserExistsResponse = new DriverUserExistsResponse();
|
|
|
|
|
int ifExists = 1;
|
|
|
|
|
if(driverUserDB == null){
|
|
|
|
|
ifExists = 0;
|
|
|
|
|
driverUserExistsResponse.setDriverPhone(driverPhone);
|
|
|
|
|
driverUserExistsResponse.setIfExits(ifExists);
|
|
|
|
|
}else{
|
|
|
|
|
driverUserExistsResponse.setDriverPhone(driverUserDB.getDriverPhone());
|
|
|
|
|
driverUserExistsResponse.setIfExits(ifExists);
|
|
|
|
|
}
|
|
|
|
|
return ResponseResult.success(driverUserExistsResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|