[fix] 办理页业务信息走 summaryFields + biz_url 绝对化(BizUrlResolver)
build / build-push (push) Successful in 1m43s
build / build-push (push) Successful in 1m43s
- 详情出参新增 bizUrlAbs:biz_url 裸相对路径按 applyAppCode(by-code)→applyAppKey(by-key) 查应用注册表 pc_url 拼 base#path(口径同 UserHome 消息中心 jumpUrl),查不到为 null - 缓存 5min/未命中 60s,不阻断详情接口;biz_url 原值保留给 bare 态父页面接管
This commit is contained in:
@@ -85,6 +85,12 @@ public final class FlowModels {
|
||||
private String bizId;
|
||||
private String bizTitle;
|
||||
private String bizUrl;
|
||||
/**
|
||||
* 业务详情的**绝对地址**(bizUrl 为裸相对路径,由 applyAppCode 查应用注册表 pc_url 拼出,
|
||||
* 口径同消息中心跳转);无法解析为 null ⇒ 前端不渲染"查看业务详情"入口。
|
||||
* 保留 bizUrl 原值不动:嵌入/去壳态由父页面按自己路由接管,绝对地址只服务流内直开。
|
||||
*/
|
||||
private String bizUrlAbs;
|
||||
/** 业务摘要 JSON(办理页区块渲染;无富文本正文——概览 §十边界) */
|
||||
private String bizSnapshot;
|
||||
private String formDataJson;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.yunhai.flowcenter.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.yunhai.platform.openapi.base.OpenApiAppClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 办件 biz_url 绝对化(办件详情/办理页"查看业务详情")。
|
||||
*
|
||||
* <p>bizUrl 自 2026-09-26 起是**裸相对路径**(不含域名/ctx/#,见 UserMsgNotifier 跳转策略):落地基址由
|
||||
* 接收方按"页面归属"解析。消息链路(UserHome 消息中心)已按 jumpApp→application_info.pc_url 拼;
|
||||
* 流程中心自己是另一类接收方——用户在流内直接点"查看业务详情"时没有宿主页面可借基址,必须自己解析,
|
||||
* 否则裸路径会落到 flow-center 自己的 origin 上(实测 /list/detail?serid=78 404)。
|
||||
*
|
||||
* <p>解析口径与消息中心逐字一致({@code MsgCenterProxyService#jumpUrl}):绝对地址直通 → 否则
|
||||
* 按办件快照的 applyAppCode 查应用注册表 pc_url(老数据没有 app_code 时用 applyAppKey 兜底)
|
||||
* → 丢 fragment、去尾斜杠 → {@code base + "#" + path}。查不到 pc_url 返回 null(前端据此不渲染入口),**不猜**。
|
||||
*
|
||||
* <p>缓存:pc_url 属低频变更的注册表数据,按应用标识缓存 5 分钟;查无缓存 60 秒(防脏值刷重复出站)。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class BizUrlResolver {
|
||||
|
||||
private static final long HIT_TTL_MS = 5 * 60_000L;
|
||||
private static final long MISS_TTL_MS = 60_000L;
|
||||
|
||||
private final OpenApiAppClient appClient;
|
||||
|
||||
private final Map<String, CacheEntry> cache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* @param appCode 页面归属应用(办件 apply_app_code,如 notice)
|
||||
* @param appKey 验签身份 app_key(老数据 app_code 为空时的兜底)
|
||||
* @param bizUrl 办件快照里的 biz_url(裸相对路径,或历史存量绝对地址)
|
||||
* @return 绝对地址;绝对地址原样返回,无法解析返回 null
|
||||
*/
|
||||
public String resolve(String appCode, String appKey, String bizUrl) {
|
||||
if (bizUrl == null || bizUrl.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String url = bizUrl.trim();
|
||||
if (isAbsolute(url)) {
|
||||
return url;
|
||||
}
|
||||
String pcUrl = null;
|
||||
if (hasText(appCode)) {
|
||||
pcUrl = pcUrl("code:" + appCode.trim(), appClient::getAppByCode);
|
||||
}
|
||||
if (pcUrl == null && hasText(appKey)) {
|
||||
pcUrl = pcUrl("key:" + appKey.trim(), appClient::getAppByKey);
|
||||
}
|
||||
if (pcUrl == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder base = new StringBuilder(pcUrl);
|
||||
int hash = base.indexOf("#");
|
||||
if (hash >= 0) {
|
||||
base.setLength(hash);
|
||||
}
|
||||
while (base.length() > 0 && base.charAt(base.length() - 1) == '/') {
|
||||
base.setLength(base.length() - 1);
|
||||
}
|
||||
if (base.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return base + "#" + (url.startsWith("/") ? url : "/" + url);
|
||||
}
|
||||
|
||||
private static boolean isAbsolute(String url) {
|
||||
return url.startsWith("http://") || url.startsWith("https://");
|
||||
}
|
||||
|
||||
private static boolean hasText(String v) {
|
||||
return v != null && !v.trim().isEmpty();
|
||||
}
|
||||
|
||||
private String pcUrl(String cacheKey, Function<String, JsonNode> fetcher) {
|
||||
long now = System.currentTimeMillis();
|
||||
CacheEntry cached = cache.get(cacheKey);
|
||||
if (cached != null && cached.expireAt > now) {
|
||||
return cached.pcUrl;
|
||||
}
|
||||
String pcUrl = null;
|
||||
try {
|
||||
JsonNode app = fetcher.apply(cacheKey.substring(cacheKey.indexOf(':') + 1));
|
||||
if (app != null && app.hasNonNull("pcUrl")) {
|
||||
String v = app.get("pcUrl").asText(null);
|
||||
if (hasText(v)) {
|
||||
pcUrl = v.trim();
|
||||
}
|
||||
}
|
||||
if (pcUrl == null) {
|
||||
log.warn("[flow-center] biz_url 归属应用无 pc_url,跳转入口隐藏:{}", cacheKey);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 不可达按 miss 缓存,避免办件详情页每请求打一次 UserBase
|
||||
log.warn("[flow-center] biz_url 归属应用查址失败(UserBase 不可达?){}:{}", cacheKey, e.toString());
|
||||
}
|
||||
cache.put(cacheKey, new CacheEntry(pcUrl, now + (pcUrl == null ? MISS_TTL_MS : HIT_TTL_MS)));
|
||||
return pcUrl;
|
||||
}
|
||||
|
||||
private static final class CacheEntry {
|
||||
private final String pcUrl;
|
||||
private final long expireAt;
|
||||
|
||||
private CacheEntry(String pcUrl, long expireAt) {
|
||||
this.pcUrl = pcUrl;
|
||||
this.expireAt = expireAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ public class FlowQueryService {
|
||||
private final FlwDefRepository defRepository;
|
||||
private final FlowDeptAdminService deptAdminService;
|
||||
private final FlowEngine flowEngine;
|
||||
private final BizUrlResolver bizUrlResolver;
|
||||
|
||||
public BasePageResult<FlowModels.InstanceItem> pageMy(Long schId, Integer submitterId,
|
||||
Integer status, String appKey, Integer page, Integer size) {
|
||||
@@ -152,6 +153,8 @@ public class FlowQueryService {
|
||||
detail.setBizId(instance.getBizId());
|
||||
detail.setBizTitle(instance.getBizTitle());
|
||||
detail.setBizUrl(instance.getBizUrl());
|
||||
detail.setBizUrlAbs(bizUrlResolver.resolve(
|
||||
instance.getApplyAppCode(), instance.getApplyAppKey(), instance.getBizUrl()));
|
||||
detail.setBizSnapshot(instance.getBizSnapshot());
|
||||
detail.setFormDataJson(instance.getFormDataJson());
|
||||
detail.setStatus(instance.getStatus());
|
||||
|
||||
Reference in New Issue
Block a user