diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/CarVinController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/CarVinController.java index 696e40761..7bccf1356 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/CarVinController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/CarVinController.java @@ -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; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/ICarVinInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/ICarVinInfoService.java index 5b1c55849..d7f96d007 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/ICarVinInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/ICarVinInfoService.java @@ -89,4 +89,10 @@ public interface ICarVinInfoService { * @return */ int bindAuthCard(CarVinDTO dto); + + /** + * 用户解绑车辆vin信息 + * @param dto + */ + int unbindCarVin(CarVinDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/CarVinInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/CarVinInfoServiceImpl.java index 289900743..1fe9817d9 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/CarVinInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/CarVinInfoServiceImpl.java @@ -8,6 +8,7 @@ import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.MemberBasicInfo; +import com.jsowell.pile.domain.PileAuthCard; import com.jsowell.pile.dto.CarVinDTO; import com.jsowell.pile.service.IMemberBasicInfoService; import com.jsowell.pile.vo.CarVinInfoVO; @@ -163,4 +164,25 @@ public class CarVinInfoServiceImpl implements ICarVinInfoService { 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); + } + + }