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);
} }
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