mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-26 05:55:03 +08:00
90 lines
3.3 KiB
Java
90 lines
3.3 KiB
Java
|
|
package com.jsowell.api.uniapp;
|
||
|
|
|
||
|
|
import com.alibaba.fastjson2.JSONObject;
|
||
|
|
import com.jsowell.common.annotation.Anonymous;
|
||
|
|
import com.jsowell.common.core.controller.BaseController;
|
||
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||
|
|
import com.jsowell.common.exception.BusinessException;
|
||
|
|
import com.jsowell.common.response.RestApiResponse;
|
||
|
|
import com.jsowell.pile.dto.CarVinDTO;
|
||
|
|
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||
|
|
import com.jsowell.pile.service.ICarVinInfoService;
|
||
|
|
import com.jsowell.pile.vo.CarVinInfoVO;
|
||
|
|
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.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* TODO
|
||
|
|
*
|
||
|
|
* @author JS-ZZA
|
||
|
|
* @date 2023/6/8 13:56
|
||
|
|
*/
|
||
|
|
@Anonymous
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/uniapp/carVin")
|
||
|
|
public class CarVinController extends BaseController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ICarVinInfoService carVinInfoService;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private MemberService memberService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户查询绑定的vin列表
|
||
|
|
* @param request
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@PostMapping("/getCarVinList")
|
||
|
|
public RestApiResponse<?> getCarVinList(HttpServletRequest request){
|
||
|
|
RestApiResponse<?> response = null;
|
||
|
|
try {
|
||
|
|
String memberId = getMemberIdByAuthorization(request);
|
||
|
|
logger.info("查询用户Vin列表 param memberId:{}", memberId);
|
||
|
|
List<CarVinInfoVO> list = carVinInfoService.getCarVinListByMemberId(memberId);
|
||
|
|
response = new RestApiResponse<>(list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("查询用户Vin列表 error", e);
|
||
|
|
response = new RestApiResponse<>(e);
|
||
|
|
}
|
||
|
|
logger.info("查询用户Vin列表 result : {}", response);
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/bindCarVin")
|
||
|
|
public RestApiResponse<?> bindCarVin(HttpServletRequest request, 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);
|
||
|
|
// 校验短信验证码
|
||
|
|
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){
|
||
|
|
logger.warn("用户绑定Vin warn:", e);
|
||
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("用户绑定Vin error", e);
|
||
|
|
response = new RestApiResponse<>(e);
|
||
|
|
}
|
||
|
|
logger.info("用户绑定Vin result:{}", response);
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
}
|