Compare commits

..

2 Commits

@ -0,0 +1,25 @@
package com.taxi.apidriver.controller;
import com.internal.dto.ResponseResult;
import com.internal.request.VerificationCodeDTO;
import com.taxi.apidriver.service.VerficationCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
public class VerficationCodeController {
@Autowired
private VerficationCodeService verficationCodeService;
@GetMapping("/verfication-code")
public ResponseResult verficationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
String driverPhone = verificationCodeDTO.getDriverPhone();
log.info("司机的号码"+driverPhone);
return verficationCodeService.checkSendVerficationCode(driverPhone);
}
}

@ -0,0 +1,24 @@
package com.taxi.apidriver.service;
import com.internal.dto.ResponseResult;
import com.internal.request.VerificationCodeDTO;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
@Service
public class VerficationCodeService {
public ResponseResult checkSendVerficationCode(String driverPhone){
//查询该手机号的司机是否存在
//获取验证码
//调用三方,获取验证码
//存入redis
return ResponseResult.success();
}
}

@ -32,6 +32,8 @@ CommonStatusEnum {
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;
/**
* 1:
* 0
*
*/
public static final int DRIVER_USER_STATE_VALID = 1;
public static final int DRIVER_USER_STATE_INVALID = 0;
}

@ -9,5 +9,7 @@ public class VerificationCodeDTO {
private String verificationCode;
private String driverPhone;
}

@ -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.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);
}
}

@ -1,12 +1,18 @@
package com.taxi.servicedriveruser.service;
import com.internal.contant.CommonStatusEnum;
import com.internal.contant.DriverCarConstant;
import com.internal.dto.DriverUser;
import com.internal.dto.ResponseResult;
import com.taxi.servicedriveruser.controller.DriverUserController;
import com.taxi.servicedriveruser.mapper.DriverUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class DriverUserService {
@ -30,4 +36,17 @@ public class DriverUserService {
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