feat(msgcenter): jumpUrl 回落链——jumpApp 优先/bizType 回落/绝对 URL 直通(自指地址 Phase 2 接收侧)+ 本地补 flow.cc/flow.returned/svc_item 三键

This commit is contained in:
chenxing
2026-09-28 11:54:35 +08:00
parent 8492fba06b
commit 7924b2d654
4 changed files with 116 additions and 12 deletions
@@ -30,6 +30,11 @@ public class MsgCenterProperties {
/** appKey → 应用显示名(消息行/弹层标签补全,如 100617 → 通知公告);未配置回退 msgType 文案 */
private Map<String, String> appNames = new LinkedHashMap<>();
/** bizType → 应用 front 基址(jumpUrl = 基址 + "/#" + jumpPath);生产同主域用相对段如 /flow-center */
/**
* 基址表:key 兼容两种查询维度——「页面归属应用」(jumpApp,发送方代发时声明,优先)与
* 「bizType」(发送方自己的消息分类,回落)。业务方应用名键(如 notice)与其主 bizType 键
* 通常重合;细分分类(notice.expedite)由发送方配 jumpApp=notice 命中应用键,无需逐分类配键。
* jumpUrl = 基址 + "/#" + jumpPath;生产同主域用相对段如 /flow-center。
*/
private Map<String, String> jumpBases = new LinkedHashMap<>();
}
@@ -182,7 +182,7 @@ public class MsgCenterProxyService {
// ===== 出参改写 =====
/** MsgListVo 逐字段透传 + jumpUrl 改写(jumpType=1 且配置了 bizType 基址时)+ 应用名补全 */
/** MsgListVo 逐字段透传 + jumpUrl 改写(jumpType=1 且查到基址时)+ 应用名补全 */
private Map<String, Object> rewrite(JsonNode row) {
Map<String, Object> out = new LinkedHashMap<>();
out.put("msgId", row.has("msgId") ? row.get("msgId").asLong() : null);
@@ -191,6 +191,7 @@ public class MsgCenterProxyService {
out.put("msgType", row.has("msgType") && row.get("msgType").isNumber() ? row.get("msgType").asInt() : null);
out.put("jumpType", row.has("jumpType") && row.get("jumpType").isNumber() ? row.get("jumpType").asInt() : null);
out.put("jumpPath", text(row, "jumpPath"));
out.put("jumpApp", text(row, "jumpApp"));
out.put("appKey", text(row, "appKey"));
String appKey = text(row, "appKey");
out.put("appName", appKey == null ? null : properties.getAppNames().get(appKey));
@@ -202,16 +203,29 @@ public class MsgCenterProxyService {
return out;
}
/** 基址 + "/#" + jumpPath;未配置基址/非应用内跳转/无路径 → null(前端不渲染跳转) */
/**
* 基址 + "/#" + jumpPath。基址查询优先「页面归属应用」(jumpApp,代发场景页面属业务方时由
* 发送方声明),缺省回落 bizType(=发送方自己的消息分类);都查不到返回 null(前端不渲染跳转)。
* jumpPath 已是绝对 URL(http/https)时直接透传——兼容存量已落库的绝对地址消息,且不再
* 重复拼基址产出双前缀畸形链接。非应用内跳转(jumpType≠1)/无路径 → null。
*/
private String jumpUrl(JsonNode row) {
Integer jumpType = row.has("jumpType") && row.get("jumpType").isNumber() ? row.get("jumpType").asInt() : null;
String jumpPath = text(row, "jumpPath");
String jumpApp = text(row, "jumpApp");
String bizType = text(row, "bizType");
if (jumpType == null || jumpType != 1 || !StringUtils.hasText(jumpPath)
|| !StringUtils.hasText(bizType)) {
if (jumpType == null || jumpType != 1 || !StringUtils.hasText(jumpPath)) {
return null;
}
String base = properties.getJumpBases().get(bizType);
String path = jumpPath.trim();
if (path.startsWith("http://") || path.startsWith("https://")) {
return path;
}
String base = StringUtils.hasText(jumpApp)
? properties.getJumpBases().get(jumpApp.trim()) : null;
if (!StringUtils.hasText(base) && StringUtils.hasText(bizType)) {
base = properties.getJumpBases().get(bizType);
}
if (!StringUtils.hasText(base)) {
return null;
}
@@ -219,8 +233,8 @@ public class MsgCenterProxyService {
while (b.endsWith("/")) {
b = b.substring(0, b.length() - 1);
}
String path = jumpPath.startsWith("/") ? jumpPath : "/" + jumpPath;
return b + "/#" + path;
String p = path.startsWith("/") ? path : "/" + path;
return b + "/#" + p;
}
private static Map<String, Object> emptyPage() {