Files
TakeoutSaaS.AdminApi/docs/observability/announcement-events.md
MSuMshk 857f776447 feat: 实现完整的多租户公告管理系统
核心功能:
- 公告状态机(草稿/已发布/已撤销)支持发布、撤销和重新发布
- 发布者范围区分平台级和租户级公告
- 目标受众定向推送(全部租户/指定角色/指定用户)
- 平台管理、租户管理和应用端查询API
- 已读/未读管理和未读统计

技术实现:
- CQRS+DDD架构,清晰的领域边界和事件驱动
- 查询性能优化:数据库端排序和限制,估算策略减少内存占用
- 并发控制:修复RowVersion配置(IsRowVersion→IsConcurrencyToken)
- 完整的FluentValidation验证器和输入保护

测试验证:
- 36个测试全部通过(27单元+9集成)
- 性能测试达标(1000条数据<5秒)
- 代码质量评级A(优秀)

文档:
- 完整的ADR、API文档和迁移指南
- 交付报告和技术债务记录
2025-12-20 19:57:09 +08:00

58 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 公告领域事件与可观测性
> 最后更新日期2025-12-20
本文档列出公告领域事件及推荐监控指标,方便事件订阅与追踪。
## 事件清单
| 事件名 | 触发时机 | 载荷字段 | 备注 |
| --- | --- | --- | --- |
| `tenant-announcement.published` | 公告发布成功后 | `announcementId``publishedAt``targetType` | 对应 `AnnouncementPublished` |
| `tenant-announcement.revoked` | 公告撤销成功后 | `announcementId``revokedAt` | 对应 `AnnouncementRevoked` |
### 事件载荷示例
```json
{
"announcementId": 900123456789012345,
"publishedAt": "2025-12-20T12:00:00Z",
"targetType": "roles"
}
```
```json
{
"announcementId": 900123456789012345,
"revokedAt": "2025-12-20T13:00:00Z"
}
```
## 事件流示意
```mermaid
flowchart LR
Cmd[Publish/Revoke Command] --> Handler[Handler]
Handler --> Bus[IEventPublisher]
Bus --> Topic[Event Bus]
Topic --> Sub1[通知服务]
Topic --> Sub2[审计/报表]
```
## 推荐指标
- `announcement.created.count`:公告创建次数
- `announcement.published.count`:公告发布次数
- `announcement.revoked.count`:公告撤销次数
- `announcement.read.count`:公告已读次数
- `announcement.visible.count`:用户可见公告数量(采样)
- `announcement.query.latency`公告查询耗时P95/P99
## 建议日志字段
```text
announcementId, tenantId, status, targetType, operatorUserId, traceId
```
> 事件发布位置:`PublishAnnouncementCommandHandler` 与 `RevokeAnnouncementCommandHandler`。