新增 用户解绑车辆vin信息接口

This commit is contained in:
Lemon
2023-06-09 10:27:27 +08:00
parent 78d65e2ca7
commit dca4f994f2
3 changed files with 73 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ import com.jsowell.pile.vo.uniapp.AuthCardVO;
import com.jsowell.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -39,6 +40,7 @@ public class CarVinController extends BaseController {
/**
* 用户查询绑定的vin列表
* http://localhost:8080/uniapp/carVin/getCarVinList
* @param request
* @return
*/
@@ -58,8 +60,15 @@ public class CarVinController extends BaseController {
return response;
}
/**
* 用户绑定车辆vin信息
* http://localhost:8080/uniapp/carVin/bindCarVin
* @param request
* @param dto
* @return
*/
@PostMapping("/bindCarVin")
public RestApiResponse<?> bindCarVin(HttpServletRequest request, CarVinDTO dto) {
public RestApiResponse<?> bindCarVin(HttpServletRequest request, @RequestBody CarVinDTO dto) {
logger.info("用户绑定Vin params: {}", JSONObject.toJSONString(dto));
RestApiResponse<?> response = null;
try {
@@ -69,11 +78,11 @@ public class CarVinController extends BaseController {
}
dto.setMemberId(memberId);
// 校验短信验证码
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
.mobileNumber(dto.getPhoneNumber())
.verificationCode(dto.getVerificationCode())
.build();
memberService.checkVerificationCode(registerAndLoginDTO);
// MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
// .mobileNumber(dto.getPhoneNumber())
// .verificationCode(dto.getVerificationCode())
// .build();
// memberService.checkVerificationCode(registerAndLoginDTO);
int i = carVinInfoService.bindAuthCard(dto);
response = new RestApiResponse<>(i);
}catch (BusinessException e){
@@ -86,4 +95,34 @@ public class CarVinController extends BaseController {
logger.info("用户绑定Vin result:{}", response);
return response;
}
/**
* 用户解绑车辆vin信息
* http://localhost:8080/uniapp/carVin/unbindCarVin
* @param request
* @param dto
* @return
*/
@PostMapping("/unbindCarVin")
public RestApiResponse<?> unbindCarVin(HttpServletRequest request, @RequestBody CarVinDTO dto) {
logger.info("用户解绑车辆vin信息 params:{}", JSONObject.toJSONString(dto));
RestApiResponse<?> response = null;
try {
String memberId = getMemberIdByAuthorization(request);
if (memberId == null) {
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
}
dto.setMemberId(memberId);
carVinInfoService.unbindCarVin(dto);
response = new RestApiResponse<>();
} catch (BusinessException e) {
logger.warn("用户解绑车辆vin信息 warn ", e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) {
logger.warn("用户解绑车辆vin信息 error ", e);
response = new RestApiResponse<>(e);
}
logger.info("用户解绑车辆vin信息 result :{}", response);
return response;
}
}