feat(msgcenter): 按应用未读数代理端点 GET /msgCenter/unreadCountByApp
build / build-push (push) Successful in 1m13s

- 签名代理 UserMsg /oapi/msg/unreadCountByApp({appKey: 未读数},口径同 unreadCount 过滤删除与过期,无未读的 appKey 不出现)
- 消息中心「按应用」清单角标数据源;UserMsg 停机降级空 Map,铃铛不 500
This commit is contained in:
chenxing
2026-10-08 11:59:52 +08:00
parent b621c959cf
commit 18e8e978a6
2 changed files with 30 additions and 0 deletions
@@ -60,6 +60,12 @@ public class MessageCenterController {
return proxy.summary(authUserWithDept.getId(), resolveSchId(authUserWithDept)); return proxy.summary(authUserWithDept.getId(), resolveSchId(authUserWithDept));
} }
/** 按来源应用未读数映射(消息中心「按应用」清单角标):{appKey: 未读数},无未读的 appKey 不出现 */
@GetMapping("msgCenter/unreadCountByApp")
public Map<String, Long> unreadCountByApp(BoaUser authUserWithDept) {
return proxy.unreadCountByApp(authUserWithDept.getId());
}
/** /**
* WS 实时推送握手地址(UserMsg 一次性票据 + 浏览器可达端点)。 * WS 实时推送握手地址(UserMsg 一次性票据 + 浏览器可达端点)。
* 未配置 WS / UserMsg 不可达 → url=null,前端维持"手动刷新"兜底表现。 * 未配置 WS / UserMsg 不可达 → url=null,前端维持"手动刷新"兜底表现。
@@ -188,6 +188,30 @@ public class MsgCenterProxyService {
return out; return out;
} }
/**
* 按来源应用未读数映射(UserMsg /oapi/msg/unreadCountByApp,{appKey: 未读数}):
* 消息中心「按应用」清单角标。口径同 unreadCount(过滤删除与过期),无未读的 appKey 不出现。
* 停机降级空 Map(铃铛不 500)。
*/
public Map<String, Long> unreadCountByApp(Integer userId) {
if (!enabled()) {
return new LinkedHashMap<>();
}
try {
Map<String, String> q = new LinkedHashMap<>();
q.put("userId", String.valueOf(userId));
JsonNode data = get("/oapi/msg/unreadCountByApp", q);
Map<String, Long> 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 带归属人防伪) */ /** 标记已读(代理按登录人发送,UserMsg 侧 UPDATE 带归属人防伪) */
public void read(Integer userId, List<Long> msgIds) { public void read(Integer userId, List<Long> msgIds) {
if (!enabled() || msgIds == null || msgIds.isEmpty()) { if (!enabled() || msgIds == null || msgIds.isEmpty()) {