Commit 3b53e691 by lixian7

调整接口返回体

parent 41e07450
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
<artifactId>sdk</artifactId> <artifactId>sdk</artifactId>
<version>${parent.version}</version> <version>${parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.hikcreate.common</groupId>
<artifactId>orika</artifactId>
<version>${parent.version}</version>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
......
...@@ -9,6 +9,7 @@ import org.springframework.cache.annotation.EnableCaching; ...@@ -9,6 +9,7 @@ import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication(scanBasePackages = "com.hikcreate.edl.pub.web.mobile", exclude = @SpringBootApplication(scanBasePackages = "com.hikcreate.edl.pub.web.mobile", exclude =
DruidDataSourceAutoConfigure.class) DruidDataSourceAutoConfigure.class)
...@@ -18,6 +19,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; ...@@ -18,6 +19,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableEurekaClient @EnableEurekaClient
@EnableApolloConfig @EnableApolloConfig
@EnableCaching @EnableCaching
@ComponentScan("com.hikcreate")
public class ApiApplication { public class ApiApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.api.controller; ...@@ -2,6 +2,7 @@ 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.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;
...@@ -15,15 +16,12 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.par ...@@ -15,15 +16,12 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.par
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper; import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery; import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.VerifyInfo; import com.hikcreate.edl.pub.web.mobile.infra.model.VerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.CheckVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes; import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.SendVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList; import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.*;
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.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -50,6 +48,8 @@ public class H5Controller { ...@@ -50,6 +48,8 @@ public class H5Controller {
VerifyInfoMapper verifyInfoMapper; VerifyInfoMapper verifyInfoMapper;
@Resource @Resource
SmsFeign smsFeign; SmsFeign smsFeign;
@Autowired
DefaultConverter defaultConverter;
/** /**
* 年检信息查询接口 * 年检信息查询接口
...@@ -59,7 +59,7 @@ public class H5Controller { ...@@ -59,7 +59,7 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 10:32 * @date: 2020/6/19 10:32
*/ */
@GetMapping("yearCheckInfo") @PostMapping("yearCheckInfo")
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated BindInfoQuery query) { public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated BindInfoQuery query) {
if (query == null) { if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
...@@ -75,7 +75,7 @@ public class H5Controller { ...@@ -75,7 +75,7 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@GetMapping("violationInfo") @PostMapping("violationInfo")
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated BindInfoQuery query) { public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated BindInfoQuery query) {
if (query == null) { if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
...@@ -91,7 +91,7 @@ public class H5Controller { ...@@ -91,7 +91,7 @@ public class H5Controller {
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@GetMapping("insuranceInfo") @PostMapping("insuranceInfo")
public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated BindInfoQuery query) { public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated BindInfoQuery query) {
if (query == null) { if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
...@@ -101,14 +101,15 @@ public class H5Controller { ...@@ -101,14 +101,15 @@ public class H5Controller {
/** /**
* 驾照信息查询接口 * 驾照信息查询接口
* header或body传值
* *
* @param query * @param query
* @return Result * @return Result
* @author: xsx * @author: xsx
* @date: 2020/6/19 16:28 * @date: 2020/6/19 16:28
*/ */
@GetMapping("drivingLicenseInfo") @PostMapping("drivingLicenseInfo")
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody BindInfoQuery query) { public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated BindInfoQuery query) {
if (query == null) { if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
} }
...@@ -120,24 +121,22 @@ public class H5Controller { ...@@ -120,24 +121,22 @@ public class H5Controller {
* @param query * @param query
* @return * @return
*/ */
@GetMapping("checkValidity") @PostMapping("checkValidity")
public Response checkValidity(@RequestBody BindInfoQuery query) { public Response<CheckValidityRes> checkValidity( @RequestBody BindInfoQuery query) {
if (query == null) { if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
} }
VerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(), VerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10)); DateUtil.offsetDay(DateTime.now(), -10));
CheckValidityRes checkValidityRes = new CheckValidityRes();
defaultConverter.getMapperFacade().map(query, checkValidityRes);
if (verifyInfo != null) { if (verifyInfo != null) {
return ResponseGenerator.success(); checkValidityRes.setIsChecked(1);
} else { } else {
SendVerifyCodeMicReq sendVerifyCodeMicReq = new SendVerifyCodeMicReq(); checkValidityRes.setIsChecked(0);
sendVerifyCodeMicReq.setUserId(query.getUserId());
sendVerifyCodeMicReq.setPhone(query.getPhone());
sendVerifyCodeMicReq.setVerifyCode(VerifyCodeUtil.getCode());
return ResponseGenerator.fail(StatusCode.PERMISSION_DENIED.getCode(), null, sendVerifyCodeMicReq);
} }
return ResponseGenerator.success(checkValidityRes);
} }
/*** /***
...@@ -149,11 +148,15 @@ public class H5Controller { ...@@ -149,11 +148,15 @@ public class H5Controller {
* @date: 2020/6/21 13:57 * @date: 2020/6/21 13:57
*/ */
@PostMapping("sendVerifyCode") @PostMapping("sendVerifyCode")
public Response sendVerifyCode(@RequestBody SendVerifyCodeMicReq req) { public Response<Void> sendVerifyCode(@RequestBody @Validated SendVerifyCodeReq req) {
if (req == null) { if (req == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
} }
return ResponseGenerator.success(smsFeign.sendVerifyCode(req)); SendVerifyCodeMicReq micReq = new SendVerifyCodeMicReq();
micReq.setPhone(req.getPhone());
micReq.setVerifyCode(VerifyCodeUtil.getCode());
micReq.setTemplateCode("PARK_LOOK_DRIVER_LICENSE");
return smsFeign.sendVerifyCode(micReq);
} }
/** /**
...@@ -165,13 +168,17 @@ public class H5Controller { ...@@ -165,13 +168,17 @@ public class H5Controller {
* @date: 2020/6/21 13:58 * @date: 2020/6/21 13:58
*/ */
@PostMapping("checkVerifyCode") @PostMapping("checkVerifyCode")
public Response sendVerifyCode(@RequestBody CheckVerifyCodeMicReq req) { public Response<Void> sendVerifyCode(@RequestBody @Validated CheckVerifyCodeReq req) {
if (req == null) { if (req == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR); return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
} }
CheckVerifyCodeMicReq micReq = new CheckVerifyCodeMicReq();
micReq.setPhone(req.getPhone());
micReq.setVerifyCode(req.getVerifyCode());
micReq.setTemplateCode("PARK_LOOK_DRIVER_LICENSE");
Result<Void> checkResult = smsFeign.checkVerifyCode(req); Response<Void> checkResult = smsFeign.checkVerifyCode(micReq);
if (ResultCode.SUCCESS.getCode().equals(checkResult.getCode())) { if (StatusCode.SUCCESS.getCode() == (checkResult.getCode())) {
VerifyInfo verifyInfo = new VerifyInfo(); VerifyInfo verifyInfo = new VerifyInfo();
verifyInfo.setUserId(req.getUserId()); verifyInfo.setUserId(req.getUserId());
verifyInfo.setVerifyCode(req.getVerifyCode()); verifyInfo.setVerifyCode(req.getVerifyCode());
...@@ -179,7 +186,7 @@ public class H5Controller { ...@@ -179,7 +186,7 @@ public class H5Controller {
verifyInfo.setPassTime(DateTime.now().toString()); verifyInfo.setPassTime(DateTime.now().toString());
verifyInfoMapper.insert(verifyInfo); verifyInfoMapper.insert(verifyInfo);
} }
return ResponseGenerator.success(checkResult); return checkResult;
} }
......
...@@ -74,6 +74,12 @@ ...@@ -74,6 +74,12 @@
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hikcreate.edl.common</groupId>
<artifactId>sdk</artifactId>
<version>${parent.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
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.edl.pub.web.mobile.infra.core.Result; import com.hikcreate.common.sdk.response.apiparam.Response;
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;
...@@ -15,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -15,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface SmsFeign { public interface SmsFeign {
@PostMapping( {"send"} ) @PostMapping( {"send"} )
Result<Void> send( @RequestBody SendMicReq req ); Response<Void> send( @RequestBody SendMicReq req );
@PostMapping( {"verifyCode/send"} ) @PostMapping( {"verifyCode/send"} )
Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req ); Response<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req );
@PostMapping( {"verifyCode/check"} ) @PostMapping( {"verifyCode/check"} )
Result<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq req); Response<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq req );
} }
\ No newline at end of file
...@@ -6,7 +6,6 @@ import lombok.experimental.Accessors; ...@@ -6,7 +6,6 @@ import lombok.experimental.Accessors;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class CheckVerifyCodeMicReq { public class CheckVerifyCodeMicReq {
private String userId;//用户ID
private String phone; // 手机号码 private String phone; // 手机号码
private String templateCode; // 短信模板编码 private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。 private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
......
...@@ -5,7 +5,6 @@ import lombok.Data; ...@@ -5,7 +5,6 @@ import lombok.Data;
@Data @Data
public class SendVerifyCodeMicReq { public class SendVerifyCodeMicReq {
private String userId;//用户ID
private String phone; // 手机号码 private String phone; // 手机号码
private String templateCode; // 短信模板编码 private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。 private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
......
...@@ -3,7 +3,6 @@ package com.hikcreate.edl.pub.web.mobile.infra.model; ...@@ -3,7 +3,6 @@ package com.hikcreate.edl.pub.web.mobile.infra.model;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
......
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author lixian
* @description
* @date 2020/6/21 14:53
**/
@Data
public class CheckVerifyCodeReq {
/**
* 绑定信息的唯一标识.
*/
@NotBlank(message = "绑定信息的唯一标识不能为空")
private String unqId;
/**
* 查询客户的id
*/
@NotBlank(message = "客户唯一编码不能为空")
private String userId;
/**
* 查询客户的电话号码
*/
@NotBlank(message = "客户手机号不能为空")
private String phone;
/**
* 短信验证码
*/
@NotBlank(message = "短信验证码不能为空")
private String verifyCode;
}
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author lixian
* @description
* @date 2020/6/21 14:46
**/
@Data
public class SendVerifyCodeReq {
/**
* 绑定信息的唯一标识.
*/
@NotBlank(message = "绑定信息的唯一标识不能为空")
private String unqId;
/**
* 查询客户的id
*/
@NotBlank(message = "客户唯一编码不能为空")
private String userId;
/**
* 查询客户的电话号码
*/
@NotBlank(message = "客户手机号不能为空")
private String phone;
}
package com.hikcreate.edl.pub.web.mobile.infra.model.param.response;
import lombok.Data;
/**
* 校验返回体
* @author lixian
* @description
* @date 2020/6/21 14:16
**/
@Data
public class CheckValidityRes {
/**
* 是否已校验,0:否,1:是
*/
private Integer isChecked;
/**
* 绑定信息的唯一标识
*/
private String unqId;
/**
* 第三方的客户id
*/
private String userId;
/**
* 查询客户的电话号码
*/
private String phone;
}
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