Commit af5cd4be by lixian7

返回体调整

parent 5554c9b6
package com.hikcreate.edl.pub.web.mobile.api.controller;
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.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.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
......@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
* @time:2020/6/18 15:59
**/
@RestController
@RequestMapping("/vehicle")
@RequestMapping( "/vehicle" )
@Slf4j
public class BindInfoControlller extends BaseController {
......@@ -49,18 +49,18 @@ public class BindInfoControlller extends BaseController {
* @author: xsx
* @date: 2020/6/19 10:27
*/
@PostMapping("bind")
@PostMapping( "bind" )
@BodyDecryptAnnotation
@ResponseEncryptAnnotation
public Response<BindInfoRes> bindInfo(@RequestBody @Validated BindInfoReq req) {
public Result<BindInfoRes> bindInfo( @RequestBody @Validated BindInfoReq req ) {
ParkBindInfo bindInfo = new ParkBindInfo();
defaultConverter.getMapperFacade().map(req, bindInfo);
Response response = null;
Result response = null;
try {
response = service.bind(bindInfo);
} catch ( DistributedLockException e ) {
log.error("分布式锁超时");
return ResponseGenerator.fail(StatusCode.REPEAT_SUBMIT);
return ResultGenerator.fail(ResultCode.REPEAT_SUBMIT);
}
return response;
}
......@@ -74,10 +74,10 @@ public class BindInfoControlller extends BaseController {
* @author: xsx
* @date: 2020/6/19 10:27
*/
@PostMapping("unbind")
@PostMapping( "unbind" )
@BodyDecryptAnnotation
public Response unbindInfo(@RequestBody @Validated UnBindReq req) {
return service.unbindInfo(req) ;
public Result unbindInfo( @RequestBody @Validated UnBindReq req ) {
return service.unbindInfo(req);
}
/**
......@@ -88,11 +88,11 @@ public class BindInfoControlller extends BaseController {
* @author: xsx
* @date: 2020/6/19 10:31
*/
@PostMapping("query")
@PostMapping( "query" )
@BodyDecryptAnnotation
@ResponseEncryptAnnotation
public Response<ResultList<BindInfoQueryRes>> bindInfoQery(@RequestBody @Validated BindInfoQueryReq query) {
return ResponseGenerator.success(new ResultList<BindInfoQueryRes>(service.selectByQuery(query)));
public Result<ResultList<BindInfoQueryRes>> bindInfoQery( @RequestBody @Validated BindInfoQueryReq query ) {
return ResultGenerator.success(new ResultList<BindInfoQueryRes>(service.selectByQuery(query)));
}
}
......@@ -3,12 +3,11 @@ package com.hikcreate.edl.pub.web.mobile.api.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
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.sdk.util.VerifyCodeUtil;
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.data.feign.edl_pub_service_sms.SmsFeign;
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;
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.SendVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.CheckValidityRes;
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 com.hikcreate.edl.pub.web.mobile.infra.model.param.response.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -44,7 +38,7 @@ import javax.annotation.Resource;
* @time:2020/6/19 16:37
**/
@RestController
@RequestMapping("/vehicle")
@RequestMapping( "/vehicle" )
@Slf4j
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;
/**
......@@ -72,9 +66,9 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/19 10:32
*/
@PostMapping("yearCheckInfo")
@PostMapping( "yearCheckInfo" )
@HeaderDecryptAnnotation
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated H5BindInfoQuery query) {
public Result<YearCheckInfoRes> yearCheckInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.yearCheckInfo(query);
}
......@@ -87,9 +81,9 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/19 16:28
*/
@PostMapping("violationInfo")
@PostMapping( "violationInfo" )
@HeaderDecryptAnnotation
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated H5BindInfoQuery query) {
public Result<ResultList<ViolationInfoRes>> violationInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.violationInfo(query);
}
......@@ -102,9 +96,9 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/19 16:28
*/
@PostMapping("insuranceInfo")
@PostMapping( "insuranceInfo" )
@HeaderDecryptAnnotation
public Result<InsuranceInfoRes> insuranceInfo( @RequestBody @Validated H5BindInfoQuery query) {
public Result<InsuranceInfoRes> insuranceInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.insuranceInfo(query);
}
......@@ -118,9 +112,9 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/19 16:28
*/
@PostMapping("drivingLicenseInfo")
@PostMapping( "drivingLicenseInfo" )
@HeaderDecryptAnnotation
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated H5BindInfoQuery query) {
public Result<DrivingLicenseInfoRes> drivingLicenseInfo( @RequestBody @Validated H5BindInfoQuery query ) {
return service.drivingLicenseInfo(query);
}
......@@ -131,21 +125,21 @@ public class H5Controller {
* @param query
* @return
*/
@PostMapping("checkValidity")
@PostMapping( "checkValidity" )
@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(),
DateUtil.offsetHour(DateTime.now(), -checkValidityLimitTime));
CheckValidityRes checkValidityRes = new CheckValidityRes();
defaultConverter.getMapperFacade().map(query, checkValidityRes);
if (verifyInfo != null) {
if ( verifyInfo != null ) {
checkValidityRes.setIsChecked(1);
} else {
checkValidityRes.setIsChecked(0);
}
return ResponseGenerator.success(checkValidityRes);
return ResultGenerator.success(checkValidityRes);
}
/***
......@@ -156,8 +150,8 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/21 13:57
*/
@PostMapping("sendVerifyCode")
public Response<Void> sendVerifyCode(@RequestBody @Validated SendVerifyCodeReq req) {
@PostMapping( "sendVerifyCode" )
public Result<Void> sendVerifyCode( @RequestBody @Validated SendVerifyCodeReq req ) {
SendVerifyCodeMicReq micReq = new SendVerifyCodeMicReq();
micReq.setPhone(req.getPhone());
......@@ -174,16 +168,16 @@ public class H5Controller {
* @author: xsx
* @date: 2020/6/21 13:58
*/
@PostMapping("checkVerifyCode")
public Response<Void> checkVerifyCode(@RequestBody @Validated CheckVerifyCodeReq req) {
@PostMapping( "checkVerifyCode" )
public Result<Void> checkVerifyCode( @RequestBody @Validated CheckVerifyCodeReq req ) {
CheckVerifyCodeMicReq micReq = new CheckVerifyCodeMicReq();
micReq.setPhone(req.getPhone());
micReq.setVerifyCode(req.getVerifyCode());
micReq.setTemplateCode("PARK_LOOK_DRIVER_LICENSE");
Response<Void> checkResult = smsFeign.checkVerifyCode(micReq);
if (StatusCode.SUCCESS.getCode() == (checkResult.getCode())) {
Result<Void> checkResult = smsFeign.checkVerifyCode(micReq);
if ( StatusCode.SUCCESS.getCode() == (checkResult.getCode()) ) {
ParkVerifyInfo verifyInfo = new ParkVerifyInfo();
verifyInfo.setUserId(req.getUserId());
verifyInfo.setVerifyCode(req.getVerifyCode());
......
......@@ -34,9 +34,9 @@ public class GlobalExceptionHandler {
@ExceptionHandler(value = ServletRequestBindingException.class)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public Response handleServletRequestBindingException(ServletRequestBindingException e) {
public Result handleServletRequestBindingException(ServletRequestBindingException 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 {
@ExceptionHandler(value = RetryableException.class)
@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);
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
unbindQuery.eq("status", "0");
Integer integer = mapper.selectCount(unbindQuery);
if (integer >= unBindCount) {
return ResultGenerator.fail(StrUtil.format("{}天内,同一用户解绑超过{}次不能再进行绑定", unBindTime / 24, unBindCount));
return ResultGenerator.fail(ResultCode.UNBIND_TOTAL_ERROR);
}
//规则:一个客户只能绑定一个电话号码
if (list != null && !list.isEmpty()) {
boolean equals = list.get(0).getPhone().equals(info.getPhone());
if (!equals) {
return ResultGenerator.fail("当前客户手机号与历史绑定手机号不一致");
return ResultGenerator.fail(ResultCode.USERID_PHONE_ERROR);
}
}
......@@ -128,7 +128,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
if (phones != null && !phones.isEmpty()) {
boolean phoneExist = phones.get(0).getUserId().equals(info.getUserId());
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;
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.SendMicReq;
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;
/**
* 短信feign
*/
@FeignClient( name = "edl-pvt-service-common",path = "sms" )
@FeignClient( name = "edl-pvt-service-common", path = "sms" )
public interface SmsFeign {
@PostMapping( {"send"} )
Response<Void> send( @RequestBody SendMicReq req );
Result<Void> send( @RequestBody SendMicReq req );
@PostMapping( {"verifyCode/send"} )
Response<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req );
Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req );
@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