mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 07:18:31 +08:00
新增 用户解绑车辆vin信息接口
This commit is contained in:
@@ -14,6 +14,7 @@ import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
|||||||
import com.jsowell.service.MemberService;
|
import com.jsowell.service.MemberService;
|
||||||
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ public class CarVinController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户查询绑定的vin列表
|
* 用户查询绑定的vin列表
|
||||||
|
* http://localhost:8080/uniapp/carVin/getCarVinList
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -58,8 +60,15 @@ public class CarVinController extends BaseController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定车辆vin信息
|
||||||
|
* http://localhost:8080/uniapp/carVin/bindCarVin
|
||||||
|
* @param request
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/bindCarVin")
|
@PostMapping("/bindCarVin")
|
||||||
public RestApiResponse<?> bindCarVin(HttpServletRequest request, CarVinDTO dto) {
|
public RestApiResponse<?> bindCarVin(HttpServletRequest request, @RequestBody CarVinDTO dto) {
|
||||||
logger.info("用户绑定Vin params: {}", JSONObject.toJSONString(dto));
|
logger.info("用户绑定Vin params: {}", JSONObject.toJSONString(dto));
|
||||||
RestApiResponse<?> response = null;
|
RestApiResponse<?> response = null;
|
||||||
try {
|
try {
|
||||||
@@ -69,11 +78,11 @@ public class CarVinController extends BaseController {
|
|||||||
}
|
}
|
||||||
dto.setMemberId(memberId);
|
dto.setMemberId(memberId);
|
||||||
// 校验短信验证码
|
// 校验短信验证码
|
||||||
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
// MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
||||||
.mobileNumber(dto.getPhoneNumber())
|
// .mobileNumber(dto.getPhoneNumber())
|
||||||
.verificationCode(dto.getVerificationCode())
|
// .verificationCode(dto.getVerificationCode())
|
||||||
.build();
|
// .build();
|
||||||
memberService.checkVerificationCode(registerAndLoginDTO);
|
// memberService.checkVerificationCode(registerAndLoginDTO);
|
||||||
int i = carVinInfoService.bindAuthCard(dto);
|
int i = carVinInfoService.bindAuthCard(dto);
|
||||||
response = new RestApiResponse<>(i);
|
response = new RestApiResponse<>(i);
|
||||||
}catch (BusinessException e){
|
}catch (BusinessException e){
|
||||||
@@ -86,4 +95,34 @@ public class CarVinController extends BaseController {
|
|||||||
logger.info("用户绑定Vin result:{}", response);
|
logger.info("用户绑定Vin result:{}", response);
|
||||||
return 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,4 +89,10 @@ public interface ICarVinInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int bindAuthCard(CarVinDTO dto);
|
int bindAuthCard(CarVinDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户解绑车辆vin信息
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
int unbindCarVin(CarVinDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.jsowell.common.exception.BusinessException;
|
|||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||||
|
import com.jsowell.pile.domain.PileAuthCard;
|
||||||
import com.jsowell.pile.dto.CarVinDTO;
|
import com.jsowell.pile.dto.CarVinDTO;
|
||||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||||
import com.jsowell.pile.vo.CarVinInfoVO;
|
import com.jsowell.pile.vo.CarVinInfoVO;
|
||||||
@@ -163,4 +164,25 @@ public class CarVinInfoServiceImpl implements ICarVinInfoService {
|
|||||||
|
|
||||||
return carVinInfoMapper.insertCarVinInfo(carVinInfo);
|
return carVinInfoMapper.insertCarVinInfo(carVinInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户解绑车辆vin信息
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int unbindCarVin(CarVinDTO dto) {
|
||||||
|
// 根据传过来的vin号查询数据库
|
||||||
|
CarVinInfo carVinInfo = selectVinInfoByVin(dto.getVinCode());
|
||||||
|
if (carVinInfo == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||||
|
}
|
||||||
|
// 如果memberId对应的上,则进行解绑操作 (将数据库中 del_flag 改为 1)
|
||||||
|
if (!StringUtils.equals(carVinInfo.getMemberId(), dto.getMemberId())) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||||
|
}
|
||||||
|
carVinInfo.setDelFlag("1");
|
||||||
|
return updateCarVinInfo(carVinInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user