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 84edd69..fb1e360 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/MessageCenterController.java @@ -29,7 +29,11 @@ public class MessageCenterController { private final MsgCenterProxyService proxy; private final MsgApprovalProxyService approvalProxy; - /** schId=0 时推断:主学校 → 主归属组(bureau)→ 0(对齐 MessageController 旧口径) */ + /** + * 会话主学校(旧口径):只供待办角标(todo)与卡片直批(flow-center 办理人学校)使用—— + * 这两条链路口径不变(方案 §8)。消息读取一律不得用它(R2:跨校切换会错), + * 必须用 {@link MsgCenterProxyService#resolveReadSchId}(当前激活身份学校)。 + */ private Integer resolveSchId(BoaUser user) { if (user.getSchool() != null) { return user.getSchool().getId(); @@ -40,6 +44,11 @@ public class MessageCenterController { return 0; } + /** 消息读取口径 schId:当前激活身份所属学校(0/平台/超管与身份链不可达 → null=看全部,D5) */ + private Integer msgSchId(BoaUser authUserWithDept) { + return proxy.resolveReadSchId(authUserWithDept.getId()); + } + /** 消息分页列表:{total, list[]}(元素含改写后的绝对 jumpUrl;UserMsg 不可达降级空)。 * 可选服务端筛选:msgType 0/1/2、appId(注册表应用 id,代理翻译下行)、isRead 0/1、keyword 标题/内容模糊(不传与现状一致)。 */ @GetMapping("msgCenter/list") @@ -51,19 +60,20 @@ public class MessageCenterController { @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "isRead", required = false) Integer isRead, @RequestParam(value = "keyword", required = false) String keyword) { - return proxy.list(authUserWithDept.getId(), page, count, onlyUnread, msgType, appId, isRead, keyword); + return proxy.list(authUserWithDept.getId(), page, count, onlyUnread, msgType, appId, isRead, keyword, + msgSchId(authUserWithDept)); } - /** 铃铛摘要:未读数 + 各应用待办角标 */ + /** 铃铛摘要:未读数 + 各应用待办角标(未读/分类计数按当前身份学校口径;待办角标沿用主学校口径不变) */ @GetMapping("msgCenter/summary") public Map summary(BoaUser authUserWithDept) { - return proxy.summary(authUserWithDept.getId(), resolveSchId(authUserWithDept)); + return proxy.summary(authUserWithDept.getId(), msgSchId(authUserWithDept), resolveSchId(authUserWithDept)); } /** 按来源应用消息计数(消息中心「按应用」清单角标):[{appId, appName, total, unread}],总数含已读 */ @GetMapping("msgCenter/countByApp") public java.util.List> countByApp(BoaUser authUserWithDept) { - return proxy.countByApp(authUserWithDept.getId()); + return proxy.countByApp(authUserWithDept.getId(), msgSchId(authUserWithDept)); } /** @@ -77,16 +87,16 @@ public class MessageCenterController { return out; } - /** 标记单条已读(按登录人代理,UserMsg 侧带归属人防伪) */ + /** 标记单条已读(按登录人代理,UserMsg 侧带归属人防伪;schId 只用于缓存失效键与 readState 口径) */ @PostMapping("msgCenter/read") public void read(BoaUser authUserWithDept, @RequestParam("msgId") Long msgId) { - proxy.read(authUserWithDept.getId(), Collections.singletonList(msgId)); + proxy.read(authUserWithDept.getId(), Collections.singletonList(msgId), msgSchId(authUserWithDept)); } - /** 全部已读 */ + /** 全部已读(按当前身份学校限定:只标本校+平台未读,他校未读不受影响,D6) */ @PostMapping("msgCenter/readAll") public void readAll(BoaUser authUserWithDept) { - proxy.readAll(authUserWithDept.getId()); + proxy.readAll(authUserWithDept.getId(), msgSchId(authUserWithDept)); } /** diff --git a/src/main/java/com/yunhai/userhome/service/MsgApprovalProxyService.java b/src/main/java/com/yunhai/userhome/service/MsgApprovalProxyService.java index 9a0a7b5..2bb653e 100644 --- a/src/main/java/com/yunhai/userhome/service/MsgApprovalProxyService.java +++ b/src/main/java/com/yunhai/userhome/service/MsgApprovalProxyService.java @@ -107,7 +107,8 @@ public class MsgApprovalProxyService { return fail(out, "流程中心暂不可用,请稍后重试"); } - msgProxy.read(userId, java.util.Collections.singletonList(msgId)); + // 直批后标读:schId 用消息读取口径(当前激活身份学校),保证 UserMsg 侧失效的是本校缓存键 + msgProxy.read(userId, java.util.Collections.singletonList(msgId), msgProxy.resolveReadSchId(userId)); out.put("ok", true); out.put("message", "办理成功"); return out; diff --git a/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java b/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java index 5aa57c7..a46e953 100644 --- a/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java +++ b/src/main/java/com/yunhai/userhome/service/MsgCenterProxyService.java @@ -3,7 +3,15 @@ package com.yunhai.userhome.service; import com.fasterxml.jackson.databind.JsonNode; import com.yunhai.platform.openapi.core.TargetSpec; import com.yunhai.platform.openapi.core.YschOpenCall; +import com.yunhai.platform.openapi.msg.OpenApiMsgClient; +import com.yunhai.platform.openapi.msg.impl.DefaultOpenApiMsgClient; +import com.yunhai.platform.openapi.msg.model.AppMsgCount; +import com.yunhai.platform.openapi.msg.model.MsgListItem; +import com.yunhai.platform.openapi.msg.model.MsgListPage; +import com.yunhai.platform.openapi.msg.model.MsgListQuery; +import com.yunhai.platform.openapi.msg.model.UserMsgSummary; import com.yunhai.userhome.config.MsgCenterProperties; +import com.yunhai.userhome.entity.UserCurrentRole; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -21,8 +29,11 @@ import java.util.Set; * (Tier 0,per-target base-path 剥离——客户端签名 path ≡ UserMsg requestURI 减 context-path), * UserHome 前端不直连 UserMsg。 *