Commit af5cd4be by lixian7

返回体调整

parent 5554c9b6
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,12 +3,11 @@ package com.hikcreate.edl.pub.web.mobile.api.controller; ...@@ -3,12 +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.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;
...@@ -18,12 +17,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkVerifyInfo; ...@@ -18,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;
...@@ -44,7 +38,7 @@ import javax.annotation.Resource; ...@@ -44,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 {
...@@ -61,7 +55,7 @@ public class H5Controller { ...@@ -61,7 +55,7 @@ public class H5Controller {
* 验证有效性限制时间 * 验证有效性限制时间
* 单位:小时 * 单位:小时
*/ */
@Value("${biz.check.validity.limit.time:24}") @Value( "${biz.check.validity.limit.time:24}" )
Integer checkValidityLimitTime; Integer checkValidityLimitTime;
/** /**
...@@ -72,9 +66,9 @@ public class H5Controller { ...@@ -72,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);
} }
...@@ -87,9 +81,9 @@ public class H5Controller { ...@@ -87,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);
} }
...@@ -102,9 +96,9 @@ public class H5Controller { ...@@ -102,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 Result<InsuranceInfoRes> insuranceInfo( @RequestBody @Validated H5BindInfoQuery query) { public Result<InsuranceInfoRes> insuranceInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.insuranceInfo(query); return service.insuranceInfo(query);
} }
...@@ -118,9 +112,9 @@ public class H5Controller { ...@@ -118,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);
} }
...@@ -131,21 +125,21 @@ public class H5Controller { ...@@ -131,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);
} }
/*** /***
...@@ -156,8 +150,8 @@ public class H5Controller { ...@@ -156,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());
...@@ -174,16 +168,16 @@ public class H5Controller { ...@@ -174,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());
......
...@@ -34,9 +34,9 @@ public class GlobalExceptionHandler { ...@@ -34,9 +34,9 @@ public class GlobalExceptionHandler {
@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);
} }
/** /**
...@@ -83,9 +83,9 @@ public class GlobalExceptionHandler { ...@@ -83,9 +83,9 @@ public class GlobalExceptionHandler {
@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(), "服务请求超时或不可用");
} }
/** /**
......
...@@ -109,14 +109,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -109,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 ResultGenerator.fail(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 ResultGenerator.fail("当前客户手机号与历史绑定手机号不一致"); return ResultGenerator.fail(ResultCode.USERID_PHONE_ERROR);
} }
} }
...@@ -128,7 +128,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -128,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 ResultGenerator.fail("当前手机号已被其他客户绑定"); return ResultGenerator.fail(ResultCode.DATA_ERROR.getCode(),"当前手机号已被其他客户绑定");
} }
} }
......
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
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