统一异常处理并修正数据类型
parent
5b2284d2f5
commit
dffa4bf3a8
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zcloud.basic.info.aspect;
|
package com.zcloud.basic.info.aspect;
|
||||||
|
|
||||||
import com.alibaba.cola.dto.SingleResponse;
|
import com.alibaba.cola.dto.SingleResponse;
|
||||||
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
@ -43,26 +44,26 @@ public class SyncResponseEncryptAspect {
|
||||||
String signature = request.getHeader("X-SIGNATURE");
|
String signature = request.getHeader("X-SIGNATURE");
|
||||||
|
|
||||||
if (corpinfoId == null || timestamp == null || signature == null) {
|
if (corpinfoId == null || timestamp == null || signature == null) {
|
||||||
throw new SecurityException("缺少必要的认证头信息");
|
throw new BizException("缺少必要的认证头信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
long requestTime = Long.parseLong(timestamp);
|
long requestTime = Long.parseLong(timestamp);
|
||||||
if (Math.abs(System.currentTimeMillis() - requestTime) > TIMESTAMP_TOLERANCE) {
|
if (Math.abs(System.currentTimeMillis() - requestTime) > TIMESTAMP_TOLERANCE) {
|
||||||
throw new SecurityException("请求已过期");
|
throw new BizException("请求已过期");
|
||||||
}
|
}
|
||||||
|
|
||||||
CorpInfoKeyDO keyDO = corpInfoKeyService.getByCorpinfoId(Long.parseLong(corpinfoId));
|
CorpInfoKeyDO keyDO = corpInfoKeyService.getByCorpinfoId(Long.parseLong(corpinfoId));
|
||||||
if (keyDO == null) {
|
if (keyDO == null) {
|
||||||
throw new SecurityException("未找到对应的密钥配置");
|
throw new BizException("未找到对应的密钥配置");
|
||||||
}
|
}
|
||||||
if (keyDO.getPublicKey() == null || keyDO.getSignKey() == null) {
|
if (keyDO.getPublicKey() == null || keyDO.getSignKey() == null) {
|
||||||
throw new SecurityException("密钥配置不完整");
|
throw new BizException("密钥配置不完整");
|
||||||
}
|
}
|
||||||
|
|
||||||
String body = getRequestBody(joinPoint);
|
String body = getRequestBody(joinPoint);
|
||||||
|
|
||||||
if (!sm2Verify(signature, corpinfoId, timestamp, body, keyDO)) {
|
if (!sm2Verify(signature, corpinfoId, timestamp, body, keyDO)) {
|
||||||
throw new SecurityException("签名验证失败");
|
throw new BizException("签名验证失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class SyncDepartmentQryPageCmd {
|
||||||
@NotNull(message = "corpinfoId不能为空")
|
@NotNull(message = "corpinfoId不能为空")
|
||||||
private Long corpinfoId;
|
private Long corpinfoId;
|
||||||
private String name;
|
private String name;
|
||||||
private String parentId; // 父部门id
|
private Long parentId; // 父部门id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue