统一异常处理并修正数据类型

main
zhangyue 2026-04-24 15:42:41 +08:00
parent 5b2284d2f5
commit dffa4bf3a8
2 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.zcloud.basic.info.aspect;
import com.alibaba.cola.dto.SingleResponse;
import com.alibaba.cola.exception.BizException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -43,26 +44,26 @@ public class SyncResponseEncryptAspect {
String signature = request.getHeader("X-SIGNATURE");
if (corpinfoId == null || timestamp == null || signature == null) {
throw new SecurityException("缺少必要的认证头信息");
throw new BizException("缺少必要的认证头信息");
}
long requestTime = Long.parseLong(timestamp);
if (Math.abs(System.currentTimeMillis() - requestTime) > TIMESTAMP_TOLERANCE) {
throw new SecurityException("请求已过期");
throw new BizException("请求已过期");
}
CorpInfoKeyDO keyDO = corpInfoKeyService.getByCorpinfoId(Long.parseLong(corpinfoId));
if (keyDO == null) {
throw new SecurityException("未找到对应的密钥配置");
throw new BizException("未找到对应的密钥配置");
}
if (keyDO.getPublicKey() == null || keyDO.getSignKey() == null) {
throw new SecurityException("密钥配置不完整");
throw new BizException("密钥配置不完整");
}
String body = getRequestBody(joinPoint);
if (!sm2Verify(signature, corpinfoId, timestamp, body, keyDO)) {
throw new SecurityException("签名验证失败");
throw new BizException("签名验证失败");
}
Object result = joinPoint.proceed();

View File

@ -30,7 +30,7 @@ public class SyncDepartmentQryPageCmd {
@NotNull(message = "corpinfoId不能为空")
private Long corpinfoId;
private String name;
private String parentId; // 父部门id
private Long parentId; // 父部门id
}