Commit 40bdbbdc by lixian7

Merge branch 'dev' into 'test'

Dev

See merge request !6
parents 07384b3e af5cd4be
package com.hikcreate.edl.pub.web.mobile.api.controller; package com.hikcreate.edl.pub.web.mobile.api.controller;
import com.hikcreate.common.orika.DefaultConverter; import com.hikcreate.common.orika.DefaultConverter;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.distributed.lock.exception.DistributedLockException; import com.hikcreate.edl.common.distributed.lock.exception.DistributedLockException;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService; import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultGenerator;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.BodyDecryptAnnotation; import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.BodyDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation; import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo; import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
...@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
* @time:2020/6/18 15:59 * @time:2020/6/18 15:59
**/ **/
@RestController @RestController
@RequestMapping("/vehicle") @RequestMapping( "/vehicle" )
@Slf4j @Slf4j
public class BindInfoControlller extends BaseController { public class BindInfoControlller extends BaseController {
...@@ -49,18 +49,18 @@ public class BindInfoControlller extends BaseController { ...@@ -49,18 +49,18 @@ public class BindInfoControlller extends BaseController {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:27 * @date: 2020/6/19 10:27
*/ */
@PostMapping("bind") @PostMapping( "bind" )
@BodyDecryptAnnotation @BodyDecryptAnnotation
@ResponseEncryptAnnotation @ResponseEncryptAnnotation
public Response<BindInfoRes> bindInfo(@RequestBody @Validated BindInfoReq req) { public Result<BindInfoRes> bindInfo( @RequestBody @Validated BindInfoReq req ) {
ParkBindInfo bindInfo = new ParkBindInfo(); ParkBindInfo bindInfo = new ParkBindInfo();
defaultConverter.getMapperFacade().map(req, bindInfo); defaultConverter.getMapperFacade().map(req, bindInfo);
Response response = null; Result response = null;
try { try {
response = service.bind(bindInfo); response = service.bind(bindInfo);
} catch ( DistributedLockException e ) { } catch ( DistributedLockException e ) {
log.error("分布式锁超时"); log.error("分布式锁超时");
return ResponseGenerator.fail(StatusCode.REPEAT_SUBMIT); return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT);
} }
return response; return response;
} }
...@@ -74,10 +74,10 @@ public class BindInfoControlller extends BaseController { ...@@ -74,10 +74,10 @@ public class BindInfoControlller extends BaseController {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:27 * @date: 2020/6/19 10:27
*/ */
@PostMapping("unbind") @PostMapping( "unbind" )
@BodyDecryptAnnotation @BodyDecryptAnnotation
public Response unbindInfo(@RequestBody @Validated UnBindReq req) { public Result unbindInfo( @RequestBody @Validated UnBindReq req ) {
return service.unbindInfo(req) ; return service.unbindInfo(req);
} }
/** /**
...@@ -88,11 +88,11 @@ public class BindInfoControlller extends BaseController { ...@@ -88,11 +88,11 @@ public class BindInfoControlller extends BaseController {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:31 * @date: 2020/6/19 10:31
*/ */
@PostMapping("query") @PostMapping( "query" )
@BodyDecryptAnnotation @BodyDecryptAnnotation
@ResponseEncryptAnnotation @ResponseEncryptAnnotation
public Response<ResultList<BindInfoQueryRes>> bindInfoQery(@RequestBody @Validated BindInfoQueryReq query) { public Result<ResultList<BindInfoQueryRes>> bindInfoQery( @RequestBody @Validated BindInfoQueryReq query ) {
return ResponseGenerator.success(new ResultList<BindInfoQueryRes>(service.selectByQuery(query))); return ResultGenerator.success(new ResultList<BindInfoQueryRes>(service.selectByQuery(query)));
} }
} }
...@@ -3,11 +3,11 @@ package com.hikcreate.edl.pub.web.mobile.api.controller; ...@@ -3,11 +3,11 @@ package com.hikcreate.edl.pub.web.mobile.api.controller;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.hikcreate.common.orika.DefaultConverter; import com.hikcreate.common.orika.DefaultConverter;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode; import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.sdk.util.VerifyCodeUtil; import com.hikcreate.edl.common.sdk.util.VerifyCodeUtil;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService; import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultGenerator;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.HeaderDecryptAnnotation; import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.HeaderDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.SmsFeign; import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.SmsFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq; import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
...@@ -17,12 +17,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkVerifyInfo; ...@@ -17,12 +17,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkVerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.CheckVerifyCodeReq; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.CheckVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.SendVerifyCodeReq; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.SendVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.CheckValidityRes; import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.*;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ViolationInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.YearCheckInfoRes;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -43,7 +38,7 @@ import javax.annotation.Resource; ...@@ -43,7 +38,7 @@ import javax.annotation.Resource;
* @time:2020/6/19 16:37 * @time:2020/6/19 16:37
**/ **/
@RestController @RestController
@RequestMapping("/vehicle") @RequestMapping( "/vehicle" )
@Slf4j @Slf4j
public class H5Controller { public class H5Controller {
...@@ -60,7 +55,7 @@ public class H5Controller { ...@@ -60,7 +55,7 @@ public class H5Controller {
* 验证有效性限制时间 * 验证有效性限制时间
* 单位:小时 * 单位:小时
*/ */
@Value("${biz.check.validity.limit.time:24}") @Value( "${biz.check.validity.limit.time:24}" )
Integer checkValidityLimitTime; Integer checkValidityLimitTime;
/** /**
...@@ -71,9 +66,9 @@ public class H5Controller { ...@@ -71,9 +66,9 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:32 * @date: 2020/6/19 10:32
*/ */
@PostMapping("yearCheckInfo") @PostMapping( "yearCheckInfo" )
@HeaderDecryptAnnotation @HeaderDecryptAnnotation
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated H5BindInfoQuery query) { public Result<YearCheckInfoRes> yearCheckInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.yearCheckInfo(query); return service.yearCheckInfo(query);
} }
...@@ -86,9 +81,9 @@ public class H5Controller { ...@@ -86,9 +81,9 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@PostMapping("violationInfo") @PostMapping( "violationInfo" )
@HeaderDecryptAnnotation @HeaderDecryptAnnotation
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated H5BindInfoQuery query) { public Result<ResultList<ViolationInfoRes>> violationInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.violationInfo(query); return service.violationInfo(query);
} }
...@@ -101,9 +96,9 @@ public class H5Controller { ...@@ -101,9 +96,9 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@PostMapping("insuranceInfo") @PostMapping( "insuranceInfo" )
@HeaderDecryptAnnotation @HeaderDecryptAnnotation
public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated H5BindInfoQuery query) { public Result<InsuranceInfoRes> insuranceInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.insuranceInfo(query); return service.insuranceInfo(query);
} }
...@@ -117,9 +112,9 @@ public class H5Controller { ...@@ -117,9 +112,9 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@PostMapping("drivingLicenseInfo") @PostMapping( "drivingLicenseInfo" )
@HeaderDecryptAnnotation @HeaderDecryptAnnotation
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated H5BindInfoQuery query) { public Result<DrivingLicenseInfoRes> drivingLicenseInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.drivingLicenseInfo(query); return service.drivingLicenseInfo(query);
} }
...@@ -130,21 +125,21 @@ public class H5Controller { ...@@ -130,21 +125,21 @@ public class H5Controller {
* @param query * @param query
* @return * @return
*/ */
@PostMapping("checkValidity") @PostMapping( "checkValidity" )
@HeaderDecryptAnnotation @HeaderDecryptAnnotation
public Response<CheckValidityRes> checkValidity(@RequestBody @Validated H5BindInfoQuery query) { public Result<CheckValidityRes> checkValidity( @RequestBody @Validated H5BindInfoQuery query ) {
ParkVerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(), ParkVerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetHour(DateTime.now(), -checkValidityLimitTime)); DateUtil.offsetHour(DateTime.now(), -checkValidityLimitTime));
CheckValidityRes checkValidityRes = new CheckValidityRes(); CheckValidityRes checkValidityRes = new CheckValidityRes();
defaultConverter.getMapperFacade().map(query, checkValidityRes); defaultConverter.getMapperFacade().map(query, checkValidityRes);
if (verifyInfo != null) { if ( verifyInfo != null ) {
checkValidityRes.setIsChecked(1); checkValidityRes.setIsChecked(1);
} else { } else {
checkValidityRes.setIsChecked(0); checkValidityRes.setIsChecked(0);
} }
return ResponseGenerator.success(checkValidityRes); return ResultGenerator.success(checkValidityRes);
} }
/*** /***
...@@ -155,8 +150,8 @@ public class H5Controller { ...@@ -155,8 +150,8 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/21 13:57 * @date: 2020/6/21 13:57
*/ */
@PostMapping("sendVerifyCode") @PostMapping( "sendVerifyCode" )
public Response<Void> sendVerifyCode(@RequestBody @Validated SendVerifyCodeReq req) { public Result<Void> sendVerifyCode( @RequestBody @Validated SendVerifyCodeReq req ) {
SendVerifyCodeMicReq micReq = new SendVerifyCodeMicReq(); SendVerifyCodeMicReq micReq = new SendVerifyCodeMicReq();
micReq.setPhone(req.getPhone()); micReq.setPhone(req.getPhone());
...@@ -173,16 +168,16 @@ public class H5Controller { ...@@ -173,16 +168,16 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/21 13:58 * @date: 2020/6/21 13:58
*/ */
@PostMapping("checkVerifyCode") @PostMapping( "checkVerifyCode" )
public Response<Void> checkVerifyCode(@RequestBody @Validated CheckVerifyCodeReq req) { public Result<Void> checkVerifyCode( @RequestBody @Validated CheckVerifyCodeReq req ) {
CheckVerifyCodeMicReq micReq = new CheckVerifyCodeMicReq(); CheckVerifyCodeMicReq micReq = new CheckVerifyCodeMicReq();
micReq.setPhone(req.getPhone()); micReq.setPhone(req.getPhone());
micReq.setVerifyCode(req.getVerifyCode()); micReq.setVerifyCode(req.getVerifyCode());
micReq.setTemplateCode("PARK_LOOK_DRIVER_LICENSE"); micReq.setTemplateCode("PARK_LOOK_DRIVER_LICENSE");
Response<Void> checkResult = smsFeign.checkVerifyCode(micReq); Result<Void> checkResult = smsFeign.checkVerifyCode(micReq);
if (StatusCode.SUCCESS.getCode() == (checkResult.getCode())) { if ( StatusCode.SUCCESS.getCode() == (checkResult.getCode()) ) {
ParkVerifyInfo verifyInfo = new ParkVerifyInfo(); ParkVerifyInfo verifyInfo = new ParkVerifyInfo();
verifyInfo.setUserId(req.getUserId()); verifyInfo.setUserId(req.getUserId());
verifyInfo.setVerifyCode(req.getVerifyCode()); verifyInfo.setVerifyCode(req.getVerifyCode());
......
...@@ -4,9 +4,15 @@ import com.hikcreate.common.sdk.exception.DefaultExceptionHandler; ...@@ -4,9 +4,15 @@ import com.hikcreate.common.sdk.exception.DefaultExceptionHandler;
import com.hikcreate.common.sdk.response.apiparam.Response; import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator; import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode; import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultGenerator;
import feign.RetryableException; import feign.RetryableException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
...@@ -16,21 +22,44 @@ import org.springframework.web.bind.annotation.ResponseStatus; ...@@ -16,21 +22,44 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException; import javax.validation.ConstraintViolationException;
import java.util.List;
/** /**
* 全局异常处理类 FOR controller层以下的异常,Filter的异常不能捕获 * 全局异常处理类 FOR controller层以下的异常,Filter的异常不能捕获
*/ */
@Slf4j @Slf4j
@ControllerAdvice @ControllerAdvice
public class GlobalExceptionHandler extends DefaultExceptionHandler { public class GlobalExceptionHandler {
@Override
@ExceptionHandler(value = ServletRequestBindingException.class) @ExceptionHandler(value = ServletRequestBindingException.class)
@ResponseBody @ResponseBody
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public Response handleServletRequestBindingException(ServletRequestBindingException e) { public Result handleServletRequestBindingException(ServletRequestBindingException e) {
log.error("param bind failure", e); log.error("param bind failure", e);
return ResponseGenerator.fail(StatusCode.PARAM_ERROR.getCode(), e.getMessage()); return ResultGenerator.fail(ResultCode.PARAM_ERROR);
}
/**
* 可能原因:@Validated 注解的对象验证不通过
*
* @param e
* @return
*/
@ExceptionHandler(value = MethodArgumentNotValidException.class)
@ResponseBody
public Result<Void> handle(MethodArgumentNotValidException e) {
BindingResult bindingResult = e.getBindingResult();
String errorMessage = buildErrorMessage(bindingResult);
log.warn(errorMessage);
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
String message = "参数错误";
if (null != fieldErrors && fieldErrors.size() > 0) {
FieldError fieldError = fieldErrors.get(0);
if (null != fieldError) {
message = fieldError.getDefaultMessage();
}
}
return ResultGenerator.fail(ResultCode.PARAM_ERROR.getCode(), message);
} }
/** /**
...@@ -44,18 +73,36 @@ public class GlobalExceptionHandler extends DefaultExceptionHandler { ...@@ -44,18 +73,36 @@ public class GlobalExceptionHandler extends DefaultExceptionHandler {
@ExceptionHandler(ConstraintViolationException.class) @ExceptionHandler(ConstraintViolationException.class)
@ResponseBody @ResponseBody
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public Response handleValidationException(ConstraintViolationException e) { public Result handleValidationException( ConstraintViolationException e) {
for (ConstraintViolation<?> s : e.getConstraintViolations()) { for (ConstraintViolation<?> s : e.getConstraintViolations()) {
log.error("Request parameter is invalid {}", s.getMessage()); log.error("Request parameter is invalid {}", s.getMessage());
return ResponseGenerator.fail(StatusCode.PARAM_ERROR.getCode(), s.getMessage()); return ResultGenerator.fail(ResultCode.PARAM_ERROR);
} }
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResultGenerator.fail(ResultCode.PARAM_ERROR);
} }
@ExceptionHandler(value = RetryableException.class) @ExceptionHandler(value = RetryableException.class)
@ResponseBody @ResponseBody
public Response retryableExceptionHandler(HttpServletRequest req, RetryableException e) throws Exception { public Result retryableExceptionHandler(HttpServletRequest req, RetryableException e) throws Exception {
log.error(" connect timed out", e); log.error(" connect timed out", e);
return ResponseGenerator.fail(StatusCode.SYSTEM_ERROR.getCode(), "服务请求超时或不可用", e.getMessage()); return ResultGenerator.fail(ResultCode.SYSTEM_ERROR.getCode(), "服务请求超时或不可用");
}
/**
* 从{@code @BindingResult}中构建异常信息
* on field 'verifyCode': null];
*
* @param bindingResult 绑定结果
*/
private String buildErrorMessage(BindingResult bindingResult) {
StringBuilder sb = new StringBuilder("BindException. ");
sb.append("Field error in object '").append(bindingResult.getObjectName()).append("'. [").append(bindingResult.getTarget()).append("]");
bindingResult.getFieldErrors()
.forEach(error -> {
sb.append("\r\n on field '").append(error.getField()).append("': ");
sb.append("rejected value [").append(error.getRejectedValue()).append("]. ");
sb.append("default message [").append(error.getDefaultMessage()).append("]");
});
return sb.toString();
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.domain; ...@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.domain;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hikcreate.common.sdk.response.apiparam.Response; import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo; import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
...@@ -28,14 +29,14 @@ public interface IBindService extends IService<ParkBindInfo> { ...@@ -28,14 +29,14 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:32 * @date: 2020/6/19 10:32
*/ */
Response bind( ParkBindInfo info); Result bind( ParkBindInfo info);
/** /**
* 信息解绑 * 信息解绑
* @param req * @param req
* @return * @return
*/ */
Response unbindInfo( UnBindReq req ); Result unbindInfo( UnBindReq req );
/** /**
* 查询用户绑定信息 * 查询用户绑定信息
...@@ -50,14 +51,14 @@ public interface IBindService extends IService<ParkBindInfo> { ...@@ -50,14 +51,14 @@ public interface IBindService extends IService<ParkBindInfo> {
* @param query * @param query
* @return * @return
*/ */
Response yearCheckInfo( H5BindInfoQuery query); Result yearCheckInfo( H5BindInfoQuery query);
/** /**
* 保险信息查询接口 * 保险信息查询接口
* @param query * @param query
* @return * @return
*/ */
Response insuranceInfo( H5BindInfoQuery query); Result insuranceInfo( H5BindInfoQuery query);
/** /**
* 违法信息查询接口 * 违法信息查询接口
...@@ -67,7 +68,7 @@ public interface IBindService extends IService<ParkBindInfo> { ...@@ -67,7 +68,7 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:06 * @date: 2020/6/19 16:06
*/ */
Response violationInfo( H5BindInfoQuery query); Result violationInfo( H5BindInfoQuery query);
/** /**
* 驾照信息查询接口 * 驾照信息查询接口
...@@ -77,6 +78,6 @@ public interface IBindService extends IService<ParkBindInfo> { ...@@ -77,6 +78,6 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:29 * @date: 2020/6/19 16:29
*/ */
Response<DrivingLicenseInfoRes> drivingLicenseInfo( H5BindInfoQuery query); Result<DrivingLicenseInfoRes> drivingLicenseInfo( H5BindInfoQuery query);
} }
...@@ -5,11 +5,11 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,11 +5,11 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.distributed.lock.annotation.DistributedLock; import com.hikcreate.edl.common.distributed.lock.annotation.DistributedLock;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService; import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result.ResultGenerator;
import com.hikcreate.edl.pub.web.mobile.infra.core.util.UnqIdUtil; import com.hikcreate.edl.pub.web.mobile.infra.core.util.UnqIdUtil;
import com.hikcreate.edl.pub.web.mobile.infra.data.cache.BindCache; import com.hikcreate.edl.pub.web.mobile.infra.data.cache.BindCache;
import com.hikcreate.edl.pub.web.mobile.infra.data.cache.DrivingLicenseCache; import com.hikcreate.edl.pub.web.mobile.infra.data.cache.DrivingLicenseCache;
...@@ -89,15 +89,16 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -89,15 +89,16 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@DistributedLock(key = "'park:extend:bind:lock:userId:'+#info.userId+':timestamp:'+#info.timestamp", expireTime = 3000, waitTime = 2000, retryTimes = 50) @DistributedLock(key = "'park:extend:lock:bind:userId:'+#info.userId+':timestamp:'+#info.timestamp", expireTime =
public Response bind(ParkBindInfo info) { 3000, waitTime = 2000, retryTimes = 50)
public Result bind(ParkBindInfo info) {
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆 //判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper<ParkBindInfo> boundQuery = new QueryWrapper(); QueryWrapper<ParkBindInfo> boundQuery = new QueryWrapper();
boundQuery.eq("user_id", info.getUserId()); boundQuery.eq("user_id", info.getUserId());
boundQuery.eq("status", "1"); boundQuery.eq("status", "1");
List<ParkBindInfo> list = mapper.selectList(boundQuery); List<ParkBindInfo> list = mapper.selectList(boundQuery);
if (list != null && list.size() >= 3) { if (list != null && list.size() >= 3) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, "同一用户下,最多绑定3辆车"); return ResultGenerator.fail(ResultCode.BIND_NUM_ERROR);
} }
/** /**
* 规则:30天内,同一客户解绑超过10次不能再进行绑定 * 规则:30天内,同一客户解绑超过10次不能再进行绑定
...@@ -108,14 +109,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -108,14 +109,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
unbindQuery.eq("status", "0"); unbindQuery.eq("status", "0");
Integer integer = mapper.selectCount(unbindQuery); Integer integer = mapper.selectCount(unbindQuery);
if (integer >= unBindCount) { if (integer >= unBindCount) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, StrUtil.format("{}天内,同一用户解绑超过{}次不能再进行绑定", unBindTime/24, unBindCount)); return ResultGenerator.fail(ResultCode.UNBIND_TOTAL_ERROR);
} }
//规则:一个客户只能绑定一个电话号码 //规则:一个客户只能绑定一个电话号码
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
boolean equals = list.get(0).getPhone().equals(info.getPhone()); boolean equals = list.get(0).getPhone().equals(info.getPhone());
if (!equals) { if (!equals) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, "当前客户手机号与历史绑定手机号不一致"); return ResultGenerator.fail(ResultCode.USERID_PHONE_ERROR);
} }
} }
...@@ -127,7 +128,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -127,7 +128,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
if (phones != null && !phones.isEmpty()) { if (phones != null && !phones.isEmpty()) {
boolean phoneExist = phones.get(0).getUserId().equals(info.getUserId()); boolean phoneExist = phones.get(0).getUserId().equals(info.getUserId());
if (!phoneExist) { if (!phoneExist) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, "当前手机号已被其他客户绑定"); return ResultGenerator.fail(ResultCode.DATA_ERROR.getCode(),"当前手机号已被其他客户绑定");
} }
} }
...@@ -137,7 +138,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -137,7 +138,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
req.setPlateNum(info.getPlateNum()); req.setPlateNum(info.getPlateNum());
List<VehicleRes> byPlateNum = vechicleCache.getByPlateNum(req); List<VehicleRes> byPlateNum = vechicleCache.getByPlateNum(req);
if (byPlateNum == null || byPlateNum.size() == 0) { if (byPlateNum == null || byPlateNum.size() == 0) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "车辆信息不存在"); return ResultGenerator.fail(ResultCode.CAR_MESSAGE_UNKNOWN);
} }
for (VehicleRes res : byPlateNum) { for (VehicleRes res : byPlateNum) {
...@@ -146,7 +147,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -146,7 +147,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
} }
} }
if (info.getPlateType() == null || "".equals(info.getPlateType())) { if (info.getPlateType() == null || "".equals(info.getPlateType())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "当前手机号,与车辆备案手机号不一致"); return ResultGenerator.fail(ResultCode.CAR_PHONE_UNMATCHED);
} }
//规则3:判断当前车牌号是否已绑定 //规则3:判断当前车牌号是否已绑定
...@@ -156,14 +157,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -156,14 +157,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
queryWrapper.eq("status", "1"); queryWrapper.eq("status", "1");
ParkBindInfo bindExist = mapper.selectOne(queryWrapper); ParkBindInfo bindExist = mapper.selectOne(queryWrapper);
if (bindExist != null) { if (bindExist != null) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "此车牌号已绑定"); return ResultGenerator.fail(ResultCode.CAR_HAVE_BIND);
} }
info.setUnqId(unqIdUtil.getUnqId()); info.setUnqId(unqIdUtil.getUnqId());
info.setGmtBindTime(new Date()); info.setGmtBindTime(new Date());
bindCache.insert(info); bindCache.insert(info);
return ResponseGenerator.success(new BindInfoRes(info.getUnqId())); return ResultGenerator.success(new BindInfoRes(info.getUnqId()));
} }
/** /**
...@@ -174,18 +175,20 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -174,18 +175,20 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Response unbindInfo(UnBindReq req) { @DistributedLock(key = "'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req" +
".timestamp", expireTime = 3000, waitTime = 2000, retryTimes = 50)
public Result unbindInfo(UnBindReq req) {
ParkBindInfo bindInfo = bindCache.getById(req.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(req.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "绑定信息不存在"); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
if (!bindCache.unBind(req.getUnqId(), req.getUserId())) { if (!bindCache.unBind(req.getUnqId(), req.getUserId())) {
//手动回滚 //手动回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResponseGenerator.fail(StatusCode.SYSTEM_ERROR, "解绑失败"); return ResultGenerator.fail("解绑失败");
} }
return ResponseGenerator.success(); return ResultGenerator.success();
} }
/** /**
...@@ -213,17 +216,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -213,17 +216,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
} }
@Override @Override
public Response<YearCheckInfoRes> yearCheckInfo(H5BindInfoQuery query) { public Result<YearCheckInfoRes> yearCheckInfo(H5BindInfoQuery query) {
ParkBindInfo bindInfo = bindCache.getById(query.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "绑定信息不存在"); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq(); PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum()); req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType()); req.setPlateType(bindInfo.getPlateType());
VehicleRes vehicleRes = vechicleCache.getByPlateNumAndType(req); VehicleRes vehicleRes = vechicleCache.getByPlateNumAndType(req);
if (Objects.isNull(vehicleRes)) { if (Objects.isNull(vehicleRes)) {
return ResponseGenerator.success(); return ResultGenerator.success();
} }
YearCheckInfoRes yearCheckInfoRes = new YearCheckInfoRes(); YearCheckInfoRes yearCheckInfoRes = new YearCheckInfoRes();
yearCheckInfoRes.setPlateNum(bindInfo.getPlateNum()); yearCheckInfoRes.setPlateNum(bindInfo.getPlateNum());
...@@ -236,21 +239,21 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -236,21 +239,21 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
yearCheckInfoRes.setStatus("已到期"); yearCheckInfoRes.setStatus("已到期");
} }
} }
return ResponseGenerator.success(yearCheckInfoRes); return ResultGenerator.success(yearCheckInfoRes);
} }
@Override @Override
public Response<InsuranceInfoRes> insuranceInfo(H5BindInfoQuery query) { public Result<InsuranceInfoRes> insuranceInfo(H5BindInfoQuery query) {
ParkBindInfo bindInfo = bindCache.getById(query.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "绑定信息不存在"); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq(); PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum()); req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType()); req.setPlateType(bindInfo.getPlateType());
VehicleRes vehicleRes = vechicleCache.getByPlateNumAndType(req); VehicleRes vehicleRes = vechicleCache.getByPlateNumAndType(req);
if (Objects.isNull(vehicleRes)) { if (Objects.isNull(vehicleRes)) {
return ResponseGenerator.success(); return ResultGenerator.success();
} }
InsuranceInfoRes insuranceInfoRes = new InsuranceInfoRes(); InsuranceInfoRes insuranceInfoRes = new InsuranceInfoRes();
insuranceInfoRes.setPlateNum(bindInfo.getPlateNum()); insuranceInfoRes.setPlateNum(bindInfo.getPlateNum());
...@@ -270,18 +273,18 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -270,18 +273,18 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
} else { } else {
insuranceInfoRes.setStatus("未知"); insuranceInfoRes.setStatus("未知");
} }
return ResponseGenerator.success(insuranceInfoRes); return ResultGenerator.success(insuranceInfoRes);
} }
@Override @Override
public Response<ResultList<ViolationInfoRes>> violationInfo(H5BindInfoQuery query) { public Result<ResultList<ViolationInfoRes>> violationInfo(H5BindInfoQuery query) {
/** /**
* 校验当前的绑定信息是否存在 * 校验当前的绑定信息是否存在
*/ */
ParkBindInfo bindInfo = bindCache.getById(query.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "绑定信息不存在"); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
/** /**
...@@ -308,17 +311,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -308,17 +311,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
info.setTime(res.getDate()); info.setTime(res.getDate());
violationInfoResList.add(info); violationInfoResList.add(info);
} }
return ResponseGenerator.success(new ResultList<>(violationInfoResList)); return ResultGenerator.success(new ResultList<>(violationInfoResList));
} }
@Override @Override
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(H5BindInfoQuery query) { public Result<DrivingLicenseInfoRes> drivingLicenseInfo(H5BindInfoQuery query) {
/** /**
* 校验当前的绑定信息是否存在 * 校验当前的绑定信息是否存在
*/ */
ParkBindInfo bindInfo = bindCache.getById(query.getUnqId()); ParkBindInfo bindInfo = bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) { if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR, "绑定信息不存在"); return ResultGenerator.fail(ResultCode.BIND_INFO_UNKNOWN);
} }
/** /**
...@@ -327,7 +330,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -327,7 +330,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
ParkVerifyInfo verify = verifyInfo.checkValidity(query.getPhone(), query.getUserId(), ParkVerifyInfo verify = verifyInfo.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -1)); DateUtil.offsetDay(DateTime.now(), -1));
if (verify == null) { if (verify == null) {
return ResponseGenerator.fail(StatusCode.PERMISSION_DENIED); return ResultGenerator.fail(ResultCode.PERMISSION_DENIED);
} }
/** /**
...@@ -338,7 +341,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -338,7 +341,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
vechicleInfoReq.setPlateNum(bindInfo.getPlateNum()); vechicleInfoReq.setPlateNum(bindInfo.getPlateNum());
VehicleRes byPlateNumAndType = vechicleCache.getByPlateNumAndType(vechicleInfoReq); VehicleRes byPlateNumAndType = vechicleCache.getByPlateNumAndType(vechicleInfoReq);
if (byPlateNumAndType.getSfzmhm() == null) { if (byPlateNumAndType.getSfzmhm() == null) {
return ResponseGenerator.fail(StatusCode.ALERT_ERROR,"车主身份证信息不存在"); return ResultGenerator.fail(ResultCode.DRIVING_LICENSE_UNKNOWN);
} }
/** /**
...@@ -348,7 +351,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -348,7 +351,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
idCardQueryReq.setIdCard(byPlateNumAndType.getSfzmhm()); idCardQueryReq.setIdCard(byPlateNumAndType.getSfzmhm());
DrivingLicenseRes drivingLicenseRes = drivingLicenseCache.getByIdCard(idCardQueryReq); DrivingLicenseRes drivingLicenseRes = drivingLicenseCache.getByIdCard(idCardQueryReq);
if (drivingLicenseRes == null) { if (drivingLicenseRes == null) {
return ResponseGenerator.fail(StatusCode.ALERT_ERROR,"车主驾照信息不存在"); return ResultGenerator.fail(ResultCode.DRIVING_LICENSE_UNKNOWN);
} }
/** /**
...@@ -365,7 +368,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -365,7 +368,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
result.setStatus(status); result.setStatus(status);
result.setSurplusGrade(String.valueOf(12 - Integer.parseInt(drivingLicenseRes.getLjjf()))); result.setSurplusGrade(String.valueOf(12 - Integer.parseInt(drivingLicenseRes.getLjjf())));
return ResponseGenerator.success(result); return ResultGenerator.success(result);
} }
......
package com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.common.sdk.exception.BusinessException;
import com.hikcreate.common.sdk.response.apiparam.Response;
import lombok.Data;
/**
* 统一的返回结果,作为服务间进行通信的数据协议。<br/>
* code表示状态码,不同服务不同接口会返回不同的状态码<br/>
* msg表示返回的结果信息描述<br/>
* data作为泛型参数类型,在不同接口可以定义不同的类型
*
* @param <T> 数据泛型类型
*/
@Data
public class Result<T> {
/**
* 成功标记
*/
private boolean success = true;
/**
* 状态码
*/
private long code;
/**
* 描述
*/
private String msg;
/**
* 挂载数据
*/
private T data;
public Result<T> fallback() {
return fallback(code, msg);
}
public Result<T> fallback(String msg) {
return fallback(code, msg);
}
public Result<T> fallback(long code) {
return fallback(code, msg);
}
/**
* 失败时抛出业务异常
*
* @param code 状态码
* @param msg 描述
* @return 当前对象
*/
public Result<T> fallback(long code, String msg) {
if (!success) {
BusinessException ex = new BusinessException(code, msg);
throw ex;
}
return this;
}
}
package com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author: xieshixiang
* @time:2020/6/24 10:28
**/
@AllArgsConstructor
@Getter
public enum ResultCode {
SUCCESS(1000, "操作成功"),
SYSTEM_ERROR(1001, "系统未知错误"),
PERMISSION_DENIED(1002, "没有权限"),
DATA_ERROR(1003, "数据错误"),
REPEAT_SUBMIT(1004, "重复提交"),
PARAM_ERROR(1005, "参数错误"),
BUSINESS_ERROR(1006, "业务错误"),
BIND_NUM_ERROR(1501, "同一客户绑定认证不超过3辆"),
UNBIND_TOTAL_ERROR(1502, "30天内解绑次数超过10次,不能再次绑定认证"),
USERID_PHONE_ERROR(1503, "客户ID与手机号不一致"),
CAR_MESSAGE_UNKNOWN(1504, "车辆信息不存在"),
CAR_PHONE_UNMATCHED(1505, "手机号与车辆备案手机号不一致"),
CAR_HAVE_BIND(1506, "车辆已被绑定"),
BIND_INFO_UNKNOWN(1507, "绑定认证不存在"),
DRIVING_LICENSE_UNKNOWN(1508, "车主驾照信息不存在");
/**
* 状态码
*/
private long code;
/**
* 描述信息
*/
private String msg;
}
package com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
/**
*
*/
public class ResultGenerator {
public static <T> Result<T> success() {
return new Result<>();
}
public static <T> Result<T> success(String msg, T data) {
Result<T> result = new Result<>();
result.setMsg(msg);
result.setData(data);
return result;
}
public static <T> Result<T> success(T data) {
Result<T> result = new Result<>();
result.setData(data);
return result;
}
public static <T> Result<T> success4Msg(String msg) {
Result<T> result = new Result<>();
result.setMsg(msg);
return result;
}
public static <T> Result<T> fail(String msg) {
Result<T> result = new Result<>();
result.setSuccess(false);
result.setCode(StatusCode.BUSINESS_ERROR.getCode());
result.setMsg(msg);
return result;
}
public static <T> Result<T> fail(ResultCode statusCode) {
Result<T> result = new Result<>();
result.setSuccess(false);
result.setCode(statusCode.getCode());
result.setMsg(statusCode.getMsg());
return result;
}
public static <T> Result<T> fail(long code, String msg) {
Result<T> result = new Result<>();
result.setSuccess(false);
result.setCode(code);
result.setMsg(msg);
return result;
}
public static <T> Result<T> fail(long code, String msg, T data) {
Result<T> result = new Result<>();
result.setSuccess(false);
result.setCode(code);
result.setMsg(msg);
result.setData(data);
return result;
}
public static <T> Result<T> copy(Result<?> from) {
Result<T> result = new Result<>();
result.setSuccess(from.isSuccess());
result.setCode(from.getCode());
result.setMsg(from.getMsg());
return result;
}
}
...@@ -70,6 +70,7 @@ public class BindCache { ...@@ -70,6 +70,7 @@ public class BindCache {
public boolean unBind(String unqId, String userId) { public boolean unBind(String unqId, String userId) {
ParkBindInfo bindInfo = new ParkBindInfo(); ParkBindInfo bindInfo = new ParkBindInfo();
bindInfo.setUnqId(unqId); bindInfo.setUnqId(unqId);
bindInfo.setUserId(userId);
bindInfo.setStatus("0"); bindInfo.setStatus("0");
bindInfo.setUnbindTime(new Date()); bindInfo.setUnbindTime(new Date());
return mapper.unbind(bindInfo) > 0; return mapper.unbind(bindInfo) > 0;
......
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms; package com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms;
import com.hikcreate.common.sdk.response.apiparam.Response; import com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq; import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendMicReq; import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq; import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
...@@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.RequestBody;
/** /**
* 短信feign * 短信feign
*/ */
@FeignClient( name = "edl-pvt-service-common",path = "sms" ) @FeignClient( name = "edl-pvt-service-common", path = "sms" )
public interface SmsFeign { public interface SmsFeign {
@PostMapping( {"send"} ) @PostMapping( {"send"} )
Response<Void> send( @RequestBody SendMicReq req ); Result<Void> send( @RequestBody SendMicReq req );
@PostMapping( {"verifyCode/send"} ) @PostMapping( {"verifyCode/send"} )
Response<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req ); Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req );
@PostMapping( {"verifyCode/check"} ) @PostMapping( {"verifyCode/check"} )
Response<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq req ); Result<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq req );
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</select> </select>
<update id="unbind"> <update id="unbind">
update park_bind_info as b set b.status="0",b.unbind_time=#{unbindTime} where b.unq_id=#{unqId} update park_bind_info as b set b.status='0',b.unbind_time=#{unbindTime} where b.unq_id=#{unqId} and b.user_id=#{userId} and b.status='1'
</update> </update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment