Commit Graph

3 Commits

Author SHA1 Message Date
hailin e684068eae feat(reporting): 实现事件驱动的仪表板统计架构
## 概述
将 reporting-service Dashboard 从 HTTP API 调用改为事件驱动架构,
通过消费 Kafka 事件在本地维护统计数据,实现微服务间解耦。

## 架构变更
之前: Dashboard → HTTP → planting/authorization/identity-service
现在: 各服务 → Kafka → reporting-service → 本地统计表 → Dashboard

## 新增表
- RealtimeStats: 每日实时统计 (认种数/订单数/新用户/授权数)
- GlobalStats: 全局累计统计 (总认种/总用户/总公司数)

## 新增仓储
- IRealtimeStatsRepository: 实时统计接口及实现
- IGlobalStatsRepository: 全局统计接口及实现

## Kafka 消费者更新
- identity.UserAccountCreated: 累加用户统计
- identity.UserAccountAutoCreated: 累加用户统计
- authorization-events: 累加省/市公司统计
- planting.order.paid: 累加认种统计

## Dashboard 服务更新
- getStats(): 从 GlobalStats/RealtimeStats 读取,计算环比变化
- getTrendData(): 从 RealtimeStats 获取趋势数据

## 优势
- 消除跨服务 HTTP 调用延迟
- 统计数据实时更新
- 微服务间完全解耦

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 00:25:31 -08:00
hailin 747e4ae8ef refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing
- Remove Address field from PartyEndpoint (parties connect to router themselves)
- Update K8s Discovery to only manage PartyID and Role labels
- Add Party registration and SessionEvent protobuf definitions
- Implement PartyRegistry and SessionEventBroadcaster domain logic
- Add RegisterParty and SubscribeSessionEvents gRPC handlers
- Prepare infrastructure for party-driven MPC coordination

This is the first phase of migrating from coordinator-driven to party-driven
architecture following international MPC system design patterns.
2025-12-05 08:11:28 -08:00
Developer 1fe66f34fd feat(reporting-service): Implement complete reporting service with DDD architecture
- Domain layer: ReportDefinition/ReportSnapshot aggregates, value objects (DateRange, ReportPeriod, etc.)
- Application layer: CQRS commands/queries, ReportingApplicationService
- Infrastructure layer: Prisma repositories, Redis cache, export services (Excel/CSV/PDF)
- API layer: REST controllers, DTOs with validation
- Testing: Unit tests, integration tests, E2E tests, Docker test environment
- Documentation: Architecture, API, Development, Testing, Deployment, Data Model docs
- Supports scheduled report generation, multi-format export, and data caching

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 08:12:57 -08:00