From 18e8e978a6f8f719e7f5034d3100c56173adf608 Mon Sep 17 00:00:00 2001 From: chenxing Date: Thu, 8 Oct 2026 11:59:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(msgcenter):=20=E6=8C=89=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E6=95=B0=E4=BB=A3=E7=90=86=E7=AB=AF=E7=82=B9?= =?UTF-8?q?=20GET=20/msgCenter/unreadCountByApp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 签名代理 UserMsg /oapi/msg/unreadCountByApp({appKey: 未读数},口径同 unreadCount 过滤删除与过期,无未读的 appKey 不出现) - 消息中心「按应用」清单角标数据源;UserMsg 停机降级空 Map,铃铛不 500 --- .../api/MessageCenterController.java | 6 +++++ .../service/MsgCenterProxyService.java | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java b/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java index 1444fbf..d6a0d09 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java @@ -60,6 +60,12 @@ public class MessageCenterController { return proxy.summary(authUserWithDept.getId(), resolveSchId(authUserWithDept)); } + /** 按来源应用未读数映射(消息中心「按应用」清单角标):{appKey: 未读数},无未读的 appKey 不出现 */ + @GetMapping("msgCenter/unreadCountByApp") + public Map unreadCountByApp(BoaUser authUserWithDept) { + return proxy.unreadCountByApp(authUserWithDept.getId()); + } + /** * WS 实时推送握手地址(UserMsg 一次性票据 + 浏览器可达端点)。 * 未配置 WS / UserMsg 不可达 → url=null,前端维持"手动刷新"兜底表现。 diff --git a/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java b/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java index e20635e..55c2da2 100644 --- a/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java +++ b/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java @@ -188,6 +188,30 @@ public class MsgCenterProxyService { return out; } + /** + * 按来源应用未读数映射(UserMsg /oapi/msg/unreadCountByApp,{appKey: 未读数}): + * 消息中心「按应用」清单角标。口径同 unreadCount(过滤删除与过期),无未读的 appKey 不出现。 + * 停机降级空 Map(铃铛不 500)。 + */ + public Map unreadCountByApp(Integer userId) { + if (!enabled()) { + return new LinkedHashMap<>(); + } + try { + Map q = new LinkedHashMap<>(); + q.put("userId", String.valueOf(userId)); + JsonNode data = get("/oapi/msg/unreadCountByApp", q); + Map out = new LinkedHashMap<>(); + if (data != null && data.isObject()) { + data.fields().forEachRemaining(e -> out.put(e.getKey(), e.getValue().asLong(0L))); + } + return out; + } catch (Exception e) { + log.warn("[msgcenter] UserMsg 按应用未读数不可达(降级空)userId={}:{}", userId, e.toString()); + return new LinkedHashMap<>(); + } + } + /** 标记已读(代理按登录人发送,UserMsg 侧 UPDATE 带归属人防伪) */ public void read(Integer userId, List msgIds) { if (!enabled() || msgIds == null || msgIds.isEmpty()) {