refactor(msgcenter): 目录键归一 flowcenter→flow-center(D1)——直批出站目标 key 与部署名对齐,私有键 flowcenter-base-url 改名 flow-center-base-url(MsgCenterProperties.flowCenterBaseUrl 同步),注释/常量/测试跟随;私有方法名 getFlowcenter 等为 Java 标识符按惯例保留
build / build-push (push) Successful in 1m40s

This commit is contained in:
chenxing
2026-09-28 17:22:34 +08:00
parent ae4bc5ecf6
commit 9f10d8d4eb
4 changed files with 15 additions and 15 deletions
@@ -23,9 +23,9 @@ public class MsgCenterProperties {
/** /**
* flow-center 服务基址(卡片直批 B3 出站,/oapi/flow/**);空 = 走服务目录 * flow-center 服务基址(卡片直批 B3 出站,/oapi/flow/**);空 = 走服务目录
* flowcenter(PlatformService 枚举兜底)。不可达时直批降级提示,不阻塞消息卡片。 * flow-center(PlatformService 枚举兜底,key 与部署名对齐)。不可达时直批降级提示,不阻塞消息卡片。
*/ */
private String flowcenterBaseUrl = ""; private String flowCenterBaseUrl = "";
/** /**
* 浏览器可达的 UserMsg WS 端点(实时推送握手地址);空 = 不下发 WS 地址, * 浏览器可达的 UserMsg WS 端点(实时推送握手地址);空 = 不下发 WS 地址,
@@ -26,15 +26,15 @@ import java.util.Map;
* bizId(业务记录 id)作为通用回落;bizType 过滤键用消息 jumpApp(=流程业务类型, * bizId(业务记录 id)作为通用回落;bizType 过滤键用消息 jumpApp(=流程业务类型,
* 消息 bizType「flow.task」是消息分类,与待办的 bizType 不同命名空间,勿混)。</li> * 消息 bizType「flow.task」是消息分类,与待办的 bizType 不同命名空间,勿混)。</li>
* <li>匹配 0 条=已处理或已失效;&gt;1 条(同办件多出口/多节点)=请前往详情页办理(一期不做歧义猜选)。</li> * <li>匹配 0 条=已处理或已失效;&gt;1 条(同办件多出口/多节点)=请前往详情页办理(一期不做歧义猜选)。</li>
* <li>出站走 {@link YschOpenCall} 签名直调,目标 flowcenter(服务目录/枚举兜底, * <li>出站走 {@link YschOpenCall} 签名直调,目标 flow-center(服务目录/枚举兜底,
* flowcenter-base-url 显式覆盖优先)。flow-center 不可达降级为提示,不影响消息卡片其余功能。</li> * flow-center-base-url 显式覆盖优先)。flow-center 不可达降级为提示,不影响消息卡片其余功能。</li>
* </ul> * </ul>
*/ */
@Slf4j @Slf4j
@Service @Service
public class MsgApprovalProxyService { public class MsgApprovalProxyService {
private static final String TARGET_FLOWCENTER = "flowcenter"; private static final String TARGET_FLOW_CENTER = "flow-center";
/** 我的待办分页拉取上限:5 页 × 100 条(todo 量级远小于此,防御性封顶) */ /** 我的待办分页拉取上限:5 页 × 100 条(todo 量级远小于此,防御性封顶) */
private static final int TODO_MAX_PAGES = 5; private static final int TODO_MAX_PAGES = 5;
@@ -167,19 +167,19 @@ public class MsgApprovalProxyService {
/** 显式 base-url → ad-hoc TargetSpec(对齐 usermsg 通道形态);否则按名走服务目录/枚举兜底 */ /** 显式 base-url → ad-hoc TargetSpec(对齐 usermsg 通道形态);否则按名走服务目录/枚举兜底 */
private JsonNode getFlowcenter(String path, Map<String, String> query) { private JsonNode getFlowcenter(String path, Map<String, String> query) {
String base = properties.getFlowcenterBaseUrl(); String base = properties.getFlowCenterBaseUrl();
if (StringUtils.hasText(base)) { if (StringUtils.hasText(base)) {
return openCall.get(TargetSpec.fromUrl(base.trim()), path, query, JsonNode.class); return openCall.get(TargetSpec.fromUrl(base.trim()), path, query, JsonNode.class);
} }
return openCall.get(TARGET_FLOWCENTER, path, query, JsonNode.class); return openCall.get(TARGET_FLOW_CENTER, path, query, JsonNode.class);
} }
private JsonNode postFlowcenter(String path, Map<String, String> query, Object body) { private JsonNode postFlowcenter(String path, Map<String, String> query, Object body) {
String base = properties.getFlowcenterBaseUrl(); String base = properties.getFlowCenterBaseUrl();
if (StringUtils.hasText(base)) { if (StringUtils.hasText(base)) {
return openCall.post(TargetSpec.fromUrl(base.trim()), path, query, body, JsonNode.class); return openCall.post(TargetSpec.fromUrl(base.trim()), path, query, body, JsonNode.class);
} }
return openCall.post(TARGET_FLOWCENTER, path, query, body, JsonNode.class); return openCall.post(TARGET_FLOW_CENTER, path, query, body, JsonNode.class);
} }
private static Map<String, Object> fail(Map<String, Object> out, String message) { private static Map<String, Object> fail(Map<String, Object> out, String message) {
+3 -3
View File
@@ -64,7 +64,7 @@ yh:
app-key: 100001 app-key: 100001
app-secret: ec4e860206374c80938719fff8e14a86 app-secret: ec4e860206374c80938719fff8e14a86
open: open:
# yh-openapi 服务目录:userbase/userclass/usermsg/flowcenter 枚举兜底 = base-host + 默认 ctx; # yh-openapi 服务目录:userbase/userclass/usermsg/flow-center 枚举兜底 = base-host + 默认 ctx;
# 身份密钥唯一来源 = yh.app-auth(本文件 app-auth 段),open.* 副本已删 # 身份密钥唯一来源 = yh.app-auth(本文件 app-auth 段),open.* 副本已删
base-host: http://base.yunhaixingtong.com base-host: http://base.yunhaixingtong.com
base-path: /userbase base-path: /userbase
@@ -90,9 +90,9 @@ userhome:
# 浏览器可达的 UserMsg WS 端点(实时推送)。空 = 不下发(前端维持手动刷新兜底); # 浏览器可达的 UserMsg WS 端点(实时推送)。空 = 不下发(前端维持手动刷新兜底);
# 生产经网关暴露:wss://msg.yunhaixingtong.com/usermsg/ws/msg # 生产经网关暴露:wss://msg.yunhaixingtong.com/usermsg/ws/msg
usermsg-ws-url: ws://localhost:8080/ws/msg usermsg-ws-url: ws://localhost:8080/ws/msg
# flow-center 服务基址(卡片直批 B3 出站,/oapi/flow/**)。空 = 走服务目录 flowcenter # flow-center 服务基址(卡片直批 B3 出站,/oapi/flow/**)。空 = 走服务目录 flow-center
# (PlatformService 枚举兜底);不可达时直批降级提示,不阻塞消息卡片 # (PlatformService 枚举兜底);不可达时直批降级提示,不阻塞消息卡片
flowcenter-base-url: http://localhost:8085 flow-center-base-url: http://localhost:8085
# appKey → 应用显示名(消息行应用列/铃铛标签补全;未命中回退 msgType 文案) # appKey → 应用显示名(消息行应用列/铃铛标签补全;未命中回退 msgType 文案)
app-names: app-names:
100009: 通知公告 100009: 通知公告
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.when;
@DisplayName("MsgApprovalProxyService - 卡片直批") @DisplayName("MsgApprovalProxyService - 卡片直批")
class MsgApprovalProxyServiceTest { class MsgApprovalProxyServiceTest {
private static final String FLOWCENTER_BASE = "http://flowcenter-service:10008/flow-center"; private static final String FLOW_CENTER_BASE = "http://flowcenter-service:10008/flow-center";
private YschOpenCall openCall; private YschOpenCall openCall;
private MsgCenterProxyService msgProxy; private MsgCenterProxyService msgProxy;
@@ -49,7 +49,7 @@ class MsgApprovalProxyServiceTest {
openCall = mock(YschOpenCall.class); openCall = mock(YschOpenCall.class);
msgProxy = mock(MsgCenterProxyService.class); msgProxy = mock(MsgCenterProxyService.class);
properties = new MsgCenterProperties(); properties = new MsgCenterProperties();
properties.setFlowcenterBaseUrl(FLOWCENTER_BASE); properties.setFlowCenterBaseUrl(FLOW_CENTER_BASE);
service = new MsgApprovalProxyService(openCall, msgProxy, properties); service = new MsgApprovalProxyService(openCall, msgProxy, properties);
} }
@@ -104,7 +104,7 @@ class MsgApprovalProxyServiceTest {
} }
@Test @Test
void flowcenterUnreachable_distinguishedFromZeroMatch() throws Exception { void flowCenterUnreachable_distinguishedFromZeroMatch() throws Exception {
when(msgProxy.findMessage(201, 5L)).thenReturn(flowTaskMessage()); when(msgProxy.findMessage(201, 5L)).thenReturn(flowTaskMessage());
when(openCall.get(any(TargetSpec.class), eq("/oapi/flow/tasks/todo"), anyMap(), eq(JsonNode.class))) when(openCall.get(any(TargetSpec.class), eq("/oapi/flow/tasks/todo"), anyMap(), eq(JsonNode.class)))
.thenThrow(new RuntimeException("connect timeout")); .thenThrow(new RuntimeException("connect timeout"));