Commit Graph

5 Commits

Author SHA1 Message Date
hailin c6c434a07a fix(update): 修复 app 版本更新检查路径 + 解决 MinIO presigned URL 24h 过期
Mobile 端:
- version_checker.dart: /api/app/... → /api/v1/app/... (与 Kong 路由匹配)

Backend (admin-service):
- AppVersion 实体新增 storage_key 字段(已执行 ALTER TABLE)
- FileStorageService: uploadFile 不再返回 presigned URL,只返回 objectName
- AdminVersionController: upload 后保存 storageKey,downloadUrl 设为
  /api/v1/app/version/download/{id}(稳定 API 地址,不过期)
- AppVersionController.downloadVersion: storageKey 存在时每次请求动态
  生成 presigned URL(1小时有效,只需够下载完成即可)
- AppVersionService.checkUpdate: 有 storageKey 的版本统一返回 API 下载地址

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:13:13 -08:00
hailin c1681085b8 feat(admin): App 版本管理 — 多应用支持 + 管理后台页面
为 admin-service 添加 appType 维度,支持管理 genex-mobile (用户端)
和 admin-app (发行方管理端) 两个 Flutter 应用的版本发布。
同时在 admin-web 新增完整的版本管理页面。

### 后端改动 (admin-service)

数据模型:
- 新增 AppType 枚举: GENEX_MOBILE | ADMIN_APP
- app_versions 表添加 app_type 列 (VARCHAR(20), 默认 GENEX_MOBILE)
- 重建唯一索引: (app_type, platform, version_code)
- Migration 046: ALTER TABLE + 索引重建

DDD 各层更新:
- Repository 接口/实现: 所有查询方法增加 appType 参数
- Service: checkUpdate/listVersions/createVersion 支持按 appType 过滤
  重复检测范围: 同一 appType + platform 内的 versionCode 唯一
- AdminVersionController:
  - GET  /admin/versions       增加 ?appType= 查询参数
  - POST /admin/versions       body 增加 appType 字段
  - POST /admin/versions/upload body 增加 appType 字段
- AppVersionController (移动端):
  - GET  /app/version/check    增加 ?app_type= 参数 (默认 GENEX_MOBILE)

### 前端改动 (admin-web)

新增页面 /app-versions:
- App 选择器 Tab: Genex 用户端 / 发行方管理端
- 平台过滤器: 全部 / Android / iOS
- 版本列表表格: 版本号、代码、平台、构建号、文件大小、强制更新、状态、发布日期
- 操作列: 编辑 / 启用|禁用 / 删除
- 上传对话框: 文件选择 → 自动解析包信息 → 填写表单 → 上传到 MinIO
- 编辑对话框: 更新日志、最低系统版本、强制更新、启用状态
- i18n: zh-CN / en-US / ja-JP 各 28 个新翻译键
- 侧边栏: 在「系统管理」前增加「📱 应用版本」菜单项

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 06:09:55 -08:00
hailin 2f583a0a24 fix(admin-service): 添加APK/IPA解析依赖 + 修复Platform类型推断
- 添加adbkit-apkreader, unzipper, bplist-parser
- 修复platform变量类型为Platform枚举

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 19:58:12 -08:00
hailin acaec56849 feat: 全12服务DDD重构 + 公告定向推送系统 (移植自rwadurian)
## 一、DDD + Clean Architecture 重构 (全12服务)

对全部12个微服务(9 NestJS + 3 Go)实施严格的DDD分层:

### NestJS 服务 (9个):
- auth-service: JWT策略已在domain层
- user-service: 新增 5 个 repository interface + implementation,
  5 个 value objects (Email/Phone/KycLevel/Money), 3 组 domain events
- issuer-service: 新增 5 个 repository interface + implementation,
  3 个 value objects, 2 组 domain events, external AI client port
- clearing-service: 新增 5 个 repository interface + implementation,
  2 个 value objects, domain events
- compliance-service: 新增 7 个 repository interface + implementation,
  2 个 value objects, domain events, audit logger service
- ai-service: 新增 conversation repository + TypeORM entity,
  AI agent client port 移至 domain/ports/
- notification-service: 新增 notification repository interface +
  implementation, channel providers, value objects
- telemetry-service: 新增 3 个 repository interface + implementation
- admin-service: 新增 app-version repository interface + implementation

### Go 服务 (3个):
- trading-service: 重构为 domain/application/infrastructure 分层,
  新增 repository interface + postgres 实现, matching engine 移入
  application/service, 新增 value objects (Price/Quantity/OrderSide/OrderType),
  Kafka event publisher
- translate-service: 新增 repository interface + postgres 实现,
  value objects (Address/ChainType)
- chain-indexer: 新增 repository interface + postgres 实现,
  value objects (BlockHeight/TxHash), Kafka event publisher

### 关键模式:
- NestJS: Symbol token DI (provide: Symbol → useClass: Impl)
- Go: compile-time interface check (var _ Interface = (*Impl)(nil))
- TypeORM entity 保留 domain methods (pragmatic DDD)
- Repository interface 在 domain/, 实现在 infrastructure/persistence/

## 二、公告定向推送系统 (ported from rwadurian)

在 notification-service 中新增 Announcement 公告体系,
支持管理端向全体/标签/指定用户推送消息:

### 数据库:
- 038_create_announcements.sql: 5张新表
  - announcements (公告主表)
  - announcement_tag_targets (标签定向)
  - announcement_user_targets (用户定向)
  - announcement_reads (已读记录)
  - user_tags (用户标签)

### 三种定向模式:
- ALL: 推送给全体用户
- BY_TAG: 按标签筛选用户 (用户标签与公告标签有交集)
- SPECIFIC: 指定用户ID列表

### 新增文件 (15个):
- 5 个 TypeORM entity (Announcement + Read + TagTarget + UserTarget + UserTag)
- 2 个 repository interface (IAnnouncementRepository 11方法, IUserTagRepository 6方法)
- 2 个 repository 实现 (TypeORM QueryBuilder, targeting filter SQL)
- 2 个 application service (AnnouncementService, UserTagService)
- 2 个 DTO 文件 (announcement.dto.ts, user-tag.dto.ts)
- 1 个 controller 文件 (含3个controller: AdminAnnouncement/AdminUserTag/UserAnnouncement)
- 1 个 migration SQL

### API 端点:
管理端:
  POST   /admin/announcements       创建公告(含定向配置)
  GET    /admin/announcements       公告列表
  GET    /admin/announcements/:id   公告详情
  PUT    /admin/announcements/:id   更新公告
  DELETE /admin/announcements/:id   删除公告
  GET    /admin/user-tags           所有标签(含用户数)
  POST   /admin/user-tags/:userId   添加用户标签
  DELETE /admin/user-tags/:userId   移除用户标签
  PUT    /admin/user-tags/:userId/sync  同步用户标签

用户端:
  GET    /announcements             用户公告(按定向过滤+已读状态)
  GET    /announcements/unread-count  未读数
  PUT    /announcements/:id/read    标记已读
  PUT    /announcements/read-all    全部已读

### 设计决策:
- Announcement 与现有 Notification 并存 (双轨):
  Notification = 事件驱动1:1通知, Announcement = 管理端广播/定向
- rwadurian accountSequences → gcx userIds (UUID)
- rwadurian Prisma → gcx TypeORM

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 21:11:24 -08:00
hailin e20c321d12 refactor: 遥测与版本管理拆分为独立微服务 (telemetry-service + admin-service)
架构重构: 将遥测(Telemetry)和版本管理(App Version)从 user-service 拆分为两个独立微服务,
严格遵循 DDD + Clean Architecture 四层架构。

新增服务:
- telemetry-service (:3011) — 用户心跳检测、事件采集、DAU统计、Prometheus指标
  - domain: 3实体 + 3值对象(EventName/InstallId/TimeWindow) + 2领域事件
  - infrastructure: Redis(Sorted Set心跳) + Kafka(事件发布) + Prometheus(5指标)
  - 定时任务: 每分钟在线快照、每小时清理过期、凌晨DAU精确计算、滚动DAU更新
- admin-service (:3012) — APK/IPA版本管理、OTA更新、MinIO文件存储
  - domain: 1实体 + 4值对象(VersionCode/VersionName/FileSha256/DownloadUrl)
  - infrastructure: MinIO(文件上传/下载) + APK/IPA解析器
  - 移动端: 检查更新API(无认证) + 下载重定向(预签名URL)
  - 管理端: 版本CRUD + 上传解析 + 启禁用

user-service 清理:
- 删除24个已迁移文件(4实体+4服务+4基础设施+5控制器+6DTO+1gitkeep)
- 移除不再需要的依赖: @nestjs/schedule, minio, prom-client, kafkajs
- 精简 user.module.ts,仅保留用户核心功能(Profile/KYC/Wallet/Message/Admin)

基础设施更新:
- Kong: 遥测路由 → telemetry-service:3011, 版本路由 → admin-service:3012
- docker-compose: 新增2个服务容器 + MinIO app-releases bucket
- 07开发指南: 更新为独立服务架构描述

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:30:39 -08:00