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
@@ -188,6 +188,30 @@ public class MsgCenterProxyService {
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 带归属人防伪) */
public void read(Integer userId, List<Long> msgIds) {
if (!enabled() || msgIds == null || msgIds.isEmpty()) {