Commit dfcb0319 by lixian7

违法信息查询

parent 1b4f9887
......@@ -4,6 +4,8 @@ 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.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.BodyDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.HeaderDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
......@@ -79,6 +81,7 @@ public class BindInfoControlller extends BaseController {
* @date: 2020/6/19 10:31
*/
@PostMapping("query")
@BodyDecryptAnnotation
@ResponseEncryptAnnotation
public Response<ResultList<BindInfo>> bindInfoQery(@RequestBody @Validated BindInfoQueryReq query) {
return ResponseGenerator.success(new ResultList<BindInfo>(service.selectByQuery(query)));
......
......@@ -8,6 +8,7 @@ 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.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;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
......@@ -63,6 +64,7 @@ public class H5Controller {
* @date: 2020/6/19 10:32
*/
@PostMapping("yearCheckInfo")
@HeaderDecryptAnnotation
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.yearCheckInfo(query);
......@@ -77,6 +79,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("violationInfo")
@HeaderDecryptAnnotation
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.violationInfo(query);
......@@ -91,6 +94,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("insuranceInfo")
@HeaderDecryptAnnotation
public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.insuranceInfo(query);
......@@ -106,6 +110,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("drivingLicenseInfo")
@HeaderDecryptAnnotation
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.drivingLicenseInfo(query);
......@@ -117,6 +122,7 @@ public class H5Controller {
* @return
*/
@PostMapping("checkValidity")
@HeaderDecryptAnnotation
public Response<CheckValidityRes> checkValidity( @RequestBody @Validated H5BindInfoQuery query) {
VerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
......@@ -177,6 +183,4 @@ public class H5Controller {
}
return checkResult;
}
}
......@@ -5,9 +5,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.hikcreate.edl.common.sdk.util.EncryptStringAes;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.BodyDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.HeaderDecryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.configbean.SignKeyConfigBean;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BaseEncryptReq;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
......@@ -30,6 +32,9 @@ import java.lang.reflect.Type;
@Slf4j
@ControllerAdvice
public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
@Autowired
SignKeyConfigBean signKeyConfigBean;
ObjectMapper objectMapper = new ObjectMapper();
public static void main( String[] args ) {
......@@ -44,7 +49,7 @@ public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
@Override
public HttpInputMessage beforeBodyRead( HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass ) throws IOException {
XHttpInputMessage xHttpInputMessage = new XHttpInputMessage(httpInputMessage, methodParameter);
XHttpInputMessage xHttpInputMessage = new XHttpInputMessage(httpInputMessage, methodParameter, signKeyConfigBean.getKey());
return xHttpInputMessage;
/*return new HttpInputMessage() {
......@@ -83,11 +88,13 @@ public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
private HttpHeaders headers;
private InputStream body;
private MethodParameter methodParameter;
private String key;
public XHttpInputMessage( HttpInputMessage httpInputMessage, MethodParameter methodParameter ) throws IOException {
public XHttpInputMessage( HttpInputMessage httpInputMessage, MethodParameter methodParameter, String key ) throws IOException {
this.headers = httpInputMessage.getHeaders();
this.body = httpInputMessage.getBody();
this.methodParameter = methodParameter;
this.key = key;
//解密请求数据
decrypt();
}
......@@ -111,7 +118,7 @@ public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
}
if ( StrUtil.isNotBlank(encryptStr) ) {
//解密
String decryptStr = EncryptStringAes.decryptAes(encryptStr, "AES/ECB/PKCS5Padding");
String decryptStr = EncryptStringAes.decryptAes(encryptStr, key );
this.body = IOUtils.toInputStream(decryptStr, "utf-8");
}
} catch ( Exception e ) {
......
......@@ -5,8 +5,10 @@ import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.sdk.util.EncryptStringAes;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.configbean.SignKeyConfigBean;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BaseEncryptRes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
......@@ -26,6 +28,9 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
@Slf4j
@ControllerAdvice
public class EncryptResponseBodyAdvice implements ResponseBodyAdvice {
@Autowired
SignKeyConfigBean signKeyConfigBean;
ObjectMapper objectMapper = new ObjectMapper();
@Override
......@@ -44,7 +49,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice {
Object data = result.getData();
if ( data != null ) {
String dataStr = objectMapper.writeValueAsString(data);
String encryptStr = EncryptStringAes.encryptAes(dataStr, "AES/ECB/PKCS5Padding");
String encryptStr = EncryptStringAes.encryptAes(dataStr, signKeyConfigBean.getKey());
BaseEncryptRes baseEncryptRes = new BaseEncryptRes();
baseEncryptRes.setEncData(encryptStr);
result.setData(baseEncryptRes);
......
......@@ -221,6 +221,8 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
ViolationPlateNumAndTypeQueryReq req = new ViolationPlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType());
req.setTimeEnd(new Date());
req.setTimeStart(DateUtil.offsetMonth(new Date(),-12));
List<ViolationRes> byPlateNumAndType = violationCache.getByPlateNumAndType(req);
/**
......@@ -298,7 +300,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
public void clearPast() {
DateTime now = DateTime.now();
log.info("开始清除,已过期且无效的绑定信息.当前时间:" + now);
DateTime lastMonth = DateUtil.offsetDay(now, -30);
Date lastMonth = DateUtil.offsetDay(now, -30);
Integer count = mapper.clearPast(lastMonth);
log.info("清除完毕,共清除过期且无效的绑定信息:" + count);
......
package com.hikcreate.edl.pub.web.mobile.infra.core.configbean;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
/**
* @author lixian
* @description
* @date 2020/6/21 18:41
**/
@Data
@ConfigurationProperties("biz.sign")
@Component
@RefreshScope
public class SignKeyConfigBean {
String key;
}
......@@ -13,7 +13,7 @@ import javax.validation.Valid;
*
*/
@FeignClient( name = "dcp-service-vehicle", path = "dcp/drivingLicense", contextId =
"dcp-service-vehicle-drivingLicense")
"dcp-service-vehicle-drivingLicense", url = "http://10.197.236.100:40204")
public interface DrivingLicenseFeign {
......
......@@ -22,7 +22,7 @@ public interface BindInfoMapper extends BaseMapper<BindInfo> {
Integer bindInfoInsert(BindInfo info);
Integer clearPast( Date dateTime);
Integer clearPast(Date dateTime);
Integer unbind(BindInfo info);
......
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