service-driver-user根据手机号查询司机是否存在代码实现

main
topsun 2 years ago
parent b20b37e473
commit f6c2a8ec58

@ -12,6 +12,7 @@ public class VerficationCodeService {
public ResponseResult checkSendVerficationCode(String driverPhone){ public ResponseResult checkSendVerficationCode(String driverPhone){
//查询该手机号的司机是否存在 //查询该手机号的司机是否存在
//获取验证码 //获取验证码
//调用三方,获取验证码 //调用三方,获取验证码

@ -32,6 +32,8 @@ CommonStatusEnum {
DRIVER_CAR_UNBIND_EXISTS(1503,"司机和车辆绑定关系已绑定"), DRIVER_CAR_UNBIND_EXISTS(1503,"司机和车辆绑定关系已绑定"),
DRIVER_USER_NOT_EXITST(1501,"司机不存在"),
/** /**
* *
*/ */

@ -13,4 +13,12 @@ public class DriverCarConstant {
*/ */
public static final int DRIVER_CAR_UNBIND = 2; public static final int DRIVER_CAR_UNBIND = 2;
/**
* 1:
* 0
*
*/
public static final int DRIVER_USER_STATE_VALID = 1;
public static final int DRIVER_USER_STATE_INVALID = 0;
} }

@ -0,0 +1,13 @@
package com.internal.response;
import lombok.Data;
/**
*
*/
@Data
public class DriverUserExistsResponse {
private String driverPhone;
private int ifExits;
}

@ -2,12 +2,11 @@ package com.taxi.servicedriveruser.controller;
import com.internal.dto.DriverUser; import com.internal.dto.DriverUser;
import com.internal.dto.ResponseResult; import com.internal.dto.ResponseResult;
import com.internal.response.DriverUserExistsResponse;
import com.taxi.servicedriveruser.service.DriverUserService; import com.taxi.servicedriveruser.service.DriverUserService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@ -16,15 +15,46 @@ public class DriverUserController {
@Autowired @Autowired
private DriverUserService driverUserService; private DriverUserService driverUserService;
/**
*
* @param driverUser
* @return
*/
@PostMapping("/users") @PostMapping("/users")
public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){ public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
return driverUserService.addDriverUser(driverUser); return driverUserService.addDriverUser(driverUser);
} }
/**
*
* @param driverUser
* @return
*/
@PutMapping("/user") @PutMapping("/user")
public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){ public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){
return driverUserService.updateDriverUser(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);
}
} }

@ -1,12 +1,18 @@
package com.taxi.servicedriveruser.service; package com.taxi.servicedriveruser.service;
import com.internal.contant.CommonStatusEnum;
import com.internal.contant.DriverCarConstant;
import com.internal.dto.DriverUser; import com.internal.dto.DriverUser;
import com.internal.dto.ResponseResult; import com.internal.dto.ResponseResult;
import com.taxi.servicedriveruser.controller.DriverUserController;
import com.taxi.servicedriveruser.mapper.DriverUserMapper; import com.taxi.servicedriveruser.mapper.DriverUserMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
public class DriverUserService { public class DriverUserService {
@ -30,4 +36,17 @@ public class DriverUserService {
return ResponseResult.success(); return ResponseResult.success();
} }
public ResponseResult<DriverUser> getUser(String driverPhone){
Map<String,Object> queryMap = new HashMap<>();
queryMap.put("driver_phone",driverPhone);
queryMap.put("state", DriverCarConstant.DRIVER_USER_STATE_VALID);
List<DriverUser> driverList = driverUserMapper.selectByMap(queryMap);
if(driverList.isEmpty()){
return ResponseResult.fail(CommonStatusEnum.DRIVER_USER_NOT_EXITST);
}else{
return ResponseResult.success(driverList.get(0));
}
}
} }

Loading…
Cancel
Save