单点日志

This commit is contained in:
zjf committed 2026-08-10 00:39:46 +08:00
1 parent e260c015ab
commit 287e8134db
5 files changed
+51 -37

No files matched your search

@@ -845,31 +845,18 @@ public class ThirdPartyOAuth2Service {
}
/**
* 诗画浦江单点:直连诗画开放接口获取用户,不再经对方 /login/shpj 中转。
* HTTP 原始请求/响应由 {@link com.bsd.pjcloud.thirdparty.shpj.ShpjUserClient} 写入单点日志。
* 诗画浦江单点:直连诗画开放接口获取用户。
* 成功/失败汇总日志由 Controller 统一记一条;openapi HTTP/业务失败由 ShpjUserClient 记。
*/
public ZZDUserDTO shjnsso(String accountId, String sessionId) {
String reqLog = "accountId=" + accountId + ",sessionId=" + sessionId + ",time=" + System.currentTimeMillis();
ShpjOpenapiUser openapiUser = shpjUserClient.getUserInfo(accountId, sessionId);
if (openapiUser == null || openapiUser.getIsLogin() != 1) {
recordSsoLog(UserTypeEnum.SH_OPEN_USER.getDescription() + "-失败",
"/openapi/v2/{accountId}/detail", reqLog, JSON.toJSONString(openapiUser),
"FAIL", "SHPJ_NOT_LOGIN", "请先登录诗画客户端");
throw new ThirdPartyException("请先登录诗画客户端", "SHPJ_NOT_LOGIN");
}
if (!StringUtils.hasText(openapiUser.getMobile())) {
recordSsoLog(UserTypeEnum.SH_OPEN_USER.getDescription() + "-失败",
"/openapi/v2/{accountId}/detail", reqLog, JSON.toJSONString(openapiUser),
"FAIL", "SHPJ_MOBILE_EMPTY", "诗画用户手机号为空");
throw new ThirdPartyException("诗画用户手机号为空", "SHPJ_MOBILE_EMPTY");
}
ZZDUserDTO dto = mapShpjOpenapiUserToZzdDto(openapiUser);
com.alibaba.fastjson.JSONObject okBody = new com.alibaba.fastjson.JSONObject();
okBody.put("mappedUser", JSON.toJSON(dto));
recordSsoLog(UserTypeEnum.SH_SSO.getDescription() + "-换用户成功",
"/thirdPartyOAth2/shjnsso", reqLog, okBody.toJSONString(),
"OK", "0", null);
return dto;
return mapShpjOpenapiUserToZzdDto(openapiUser);
}
private static ZZDUserDTO mapShpjOpenapiUserToZzdDto(ShpjOpenapiUser user) {
@@ -88,8 +88,7 @@ public class ShpjUserClient {
"SHPJ_BIZ_" + resp.getCode(), resp.getMessage());
throw new ThirdPartyException("诗画浦江接口调用失败:" + resp.getMessage(), "SHPJ_BIZ_" + resp.getCode());
}
thirdPartyLogService.recordSsoLog(UserTypeEnum.SH_OPEN_USER.getDescription() + "-成功",
apiUrl, reqLog, body, "OK", "0", null);
// 成功不落库:由 /shjnsso 控制器记一条汇总日志,避免一次登录多条成功记录
return resp.getData();
} catch (ThirdPartyException e) {
throw e;