hailin
c00c48c8bd
fix(notification): accept optional type query param to fix 400 error
...
Backend entity has no type column yet; whitelist the type field in DTO
so forbidNonWhitelisted doesn't reject requests from the mobile app.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 11:50:35 -08:00
hailin
9e368cbf37
fix(mobile+backend): fix notification DNS, message page API bugs, add read-all
...
Android DNS fix (native_dio_adapter):
- Dart's getaddrinfo() fails on some Android 12+ devices when browser works
fine — root cause is Dart native socket using different DNS path than
Android Java stack; fix by using NativeAdapter (OkHttp) on Android
- Add native_dio_adapter ^1.5.1 to pubspec; enable in ApiClient for Android
Message page bugs (5 fixes):
- Fix offset->page: Flutter sent ?offset=0 but backend NotificationQueryDto
uses page/limit (1-based); now sends ?page=1&limit=50
- Fix announcement tab API: Tab 2 now calls /api/v1/announcements (separate
resource) instead of /api/v1/notifications?type=ANNOUNCEMENT
- Fix markAllAsRead routing: calls correct API based on active tab
- Fix markAsRead routing: announcement items use announcements API
- Fix detail navigation: passes NotificationItem as route argument
Backend notification-service:
- Add PUT /api/v1/notifications/read-all endpoint
- Add markAllReadByUserId() to repository interface + TypeORM implementation
- Add markAllRead() to NotificationService
i18n (4 languages): add time.justNow/minutesAgo/hoursAgo/daysAgo keys
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 11:15:03 -08:00
hailin
fa512dd2eb
fix(auth): JwtStrategy.validate() return id not sub
...
All 6 service strategies were returning { sub } but controllers use req.user.id.
Change return value from { sub: payload.sub } to { id: payload.sub } so that
req.user.id resolves correctly in all protected controllers.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:52:53 -08:00
hailin
3d0223d10a
fix: add passport-jwt deps to 3 services + fix messages page UI
...
Backend:
- Add passport/passport-jwt/@types/passport-jwt to clearing-service,
compliance-service, notification-service package.json (missing deps
caused 'Cannot find module passport-jwt' build failure)
Flutter:
- MessagePage: automaticallyImplyLeading: false (no back btn on tab page)
- TabBar: isScrollable+tabAlignment.start to prevent 'Announcements' truncation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:15:00 -08:00
hailin
3b733462ce
fix(auth): add local JwtStrategy to all services, fix @genex/common import
...
6 services (user/issuer/clearing/compliance/notification/telemetry) were
missing JwtStrategy provider, causing 'Unknown authentication strategy jwt'
500 errors on all auth-protected endpoints.
- Create infrastructure/strategies/jwt.strategy.ts in each service
- Update each module to import from local path (not @genex/common)
- Revert @genex/common/index.ts strategy export (passport-jwt not in each
service's node_modules, causes runtime 'Cannot find module' error)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:00:39 -08:00
hailin
75ed31cc04
fix: 全服务注册 JwtStrategy + 修复微信 WxApi 未配置 crash
...
**后端**
- packages/common: 新增并导出 JwtStrategy(共享 Passport JWT 策略)
- 6 个服务模块(user/issuer/clearing/compliance/notification/telemetry)
均缺少 JwtStrategy provider,导致所有受保护接口返回 500
"Unknown authentication strategy jwt"
- 统一修复:各模块 providers 添加 JwtStrategy
**Flutter**
- welcome_page: _onWechatTap() 的 isWeChatInstalled 调用未设 WECHAT_APP_ID
时会抛出 PlatformException,catch 后降级为"未安装"提示
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:24:07 -08:00
hailin
e8e2d14fbc
fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health
...
NestJS服务注册了全局路由前缀 api/v1,HealthController 实际挂载在
/api/v1/health 而非 /health,导致 Docker HEALTHCHECK 返回 404。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 05:50:26 -08:00
hailin
c5787020d2
feat(health): 为全部12个微服务添加Docker健康检查
...
## 变更概要
所有后端微服务均增加 Docker HEALTHCHECK 指令,统一通过 GET /health
端点检测服务存活状态。解决 `docker ps` 中13个容器无 (healthy) 状态的问题。
## NestJS 服务 (9个)
- auth-service (:3010), user-service (:3001), issuer-service (:3002),
clearing-service (:3004), compliance-service (:3005), ai-service (:3006),
notification-service (:3008), telemetry-service (:3011), admin-service (:3012)
- 7个服务的 app.module.ts 新增 `import { HealthModule } from '@genex/common'`
注册标准健康检查控制器 (GET /health, /health/ready, /health/live)
- telemetry-service 和 admin-service 已有自建 HealthController,无需导入
- Dockerfile: HEALTHCHECK --interval=30s --start-period=15s --retries=3
## Go 服务 (3个)
- trading-service (:3003), translate-service (:3007), chain-indexer (:3009)
- 已有 /health 端点 (Gin 路由),仅 Dockerfile 添加 HEALTHCHECK
- Dockerfile: HEALTHCHECK --interval=30s --start-period=10s --retries=3
## Kafka Connect
- docker-compose.yml 添加 healthcheck (curl http://localhost:8083/ )
## 健康检查方式
- 所有服务统一使用 `wget --spider http://localhost:PORT/health `
(node:20-alpine 和 alpine:3.19 均自带 BusyBox wget)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 05:39:25 -08:00
hailin
c42827c6c1
fix(backend): 修复所有服务编译问题 — tsconfig宽松化 + 补全缺失依赖
...
- 所有tsconfig.json: strict改为false, 移除paths映射(改用node_modules解析)
- compliance/clearing/ai/notification: 添加缺失的@nestjs/passport和@nestjs/jwt
- ai-service: 添加缺失的@nestjs/config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 19:20:48 -08:00
hailin
d48bd3acb9
feat(docker): 重构Monorepo构建 — 支持@genex/common共享包
...
- docker-compose.yml build context从service目录改为backend根目录
- 所有NestJS Dockerfile改为先构建共享@genex/common包
- 共享包编译后复制到service的node_modules供运行时解析
- 新增backend/.dockerignore减少构建上下文体积
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 19:00:27 -08:00
hailin
d146bf0a1f
fix(tsconfig): 关闭strictPropertyInitialization以兼容TypeORM实体
...
TypeORM实体使用装饰器定义属性,不在构造函数中初始化。
strict:true隐式启用strictPropertyInitialization导致TS2564编译错误。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:48:48 -08:00
hailin
12bb31ede1
fix(docker): 所有NestJS服务Dockerfile使用npm install替代npm ci
...
项目未包含package-lock.json,npm ci要求该文件存在才能运行。
改用npm install确保Docker构建正常完成。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:33:31 -08:00
hailin
bc0d1e0876
feat: 新增 deploy.sh 部署管理脚本体系 — 后端主控+12服务独立+区块链
...
参照 rwadurian 项目模式,为全栈系统创建统一的 deploy.sh 管理体系:
- backend/deploy.sh: 主控脚本 (up/down/restart/build/build-no-cache/health/infra-*/单服务操作)
- 12个服务独立 deploy.sh (build/rebuild/start/stop/restart/logs/health/shell/test)
- blockchain/deploy.sh: 节点+生态+合约+浏览器+监控全覆盖
- 更新 09-编译部署指南.md 新增第9章 deploy.sh 使用文档
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:13:09 -08:00
hailin
8adead23b6
feat: 设备推送系统 — FCM/APNs/HMS/小米/OPPO/vivo 多通道推送 + PROMOTION广告类型
...
新增设备推送通道架构,支持6大推送平台的多通道路由:
【SQL迁移】
- 039_create_device_tokens.sql: device_tokens表 (userId, platform, channel, token, deviceId等)
- announcements表新增 PROMOTION 类型约束
【Domain层 — 实体/接口/端口】
- DeviceToken实体: DevicePlatform枚举(ANDROID/IOS) + PushChannel枚举(FCM/APNS/HMS/XIAOMI/OPPO/VIVO)
- IDeviceTokenRepository: 6个仓储方法 (findActive/upsert/deactivate/countByChannel)
- IPushChannelProvider端口: PushPayload/PushResult类型 + 6个DI Symbol
- AnnouncementType枚举: 新增 PROMOTION (广告/促销推送)
【Infrastructure层 — 持久化/推送通道】
- DeviceTokenRepositoryImpl: TypeORM实现,支持批量IN查询(每批500)、token upsert
- 6个推送通道Provider (mock骨架,结构完整可直接替换为真实SDK):
· FcmPushProvider — Google FCM (firebase-admin)
· ApnsPushProvider — Apple APNs (HTTP/2直连,中国区必需)
· HmsPushProvider — 华为HMS Push Kit
· XiaomiPushProvider — 小米Mi Push
· OppoPushProvider — OPPO Push
· VivoPushProvider — vivo Push
- PushNotificationProvider重构: 从mock改为委托PushDispatcherService
【Application层 — 服务】
- PushDispatcherService: 核心调度器
· sendToUser/sendToUsers → 查device tokens → 按channel分组 → 路由到对应provider
· 自动清理无效token (shouldDeactivateToken)
- DeviceTokenService: 设备token注册/注销/查询
- AnnouncementService: 公告创建后自动触发设备推送
· BY_TAG → 解析tag对应userIds → pushDispatcher.sendToUsers
· SPECIFIC → 直接推送指定userIds
【Interface层 — DTO/Controller】
- RegisterDeviceTokenDto/UnregisterDeviceTokenDto: Swagger + class-validator
- DeviceTokenController: POST/DELETE/GET /device-tokens (JWT认证)
【Module注册】
- notification.module.ts: 新增DeviceToken实体、DEVICE_TOKEN_REPOSITORY、
6个push channel provider DI绑定、PushDispatcherService、DeviceTokenService、
DeviceTokenController
推送链路: 公告创建 → triggerPush → PushDispatcher → 查token → 按channel分组 → FCM/APNs/HMS/小米/OPPO/vivo
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 23:48:52 -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
4da8a373f2
refactor: 全项目清除MVP字样,统一为正式系统用语
...
## 变更范围:21个文件,覆盖全栈
### SRS需求文档 (4个文件,20处修改)
docs/券金融平台-软件需求规格.md (7处):
- "MVP策略" → "运营策略"/"合规策略"
- "MVP阶段GNX不上交易所" → "Phase 1阶段GNX不上交易所"
- "MVP同步" → "同步发布"
- "MVP阶段优先级" → "阶段优先级"
- "Phase 1(MVP)" → "Phase 1(基础平台)"
- "基础发行与交易(MVP,仅Utility Track)" → "基础发行与交易(仅Utility Track)"
docs/券金融平台-需求规格综合评估报告.md (4处):
- "MVP分期" → "阶段分期"
- "MVP回避策略" → "合规回避策略"
- "MVP仅Utility Track" → "Phase 1仅Utility Track"
docs/闲券交易平台-架构开发需求.md (4处):
- "MVP阶段只开放" → "当前阶段只开放"
- "Phase 1(MVP)" → "Phase 1(基础平台)"
- "基础平台(MVP,仅Utility Track)" → "基础平台(仅Utility Track)"
docs/闲券平台-软件开发需求.md (5处):
- "MVP阶段用户不接触" → "当前阶段用户不接触"
- "MVP策略" → "运营策略"
- "Phase 1(MVP)" → "Phase 1(基础平台)"
- "Phase 1 — MVP" → "Phase 1 — 基础平台"
### 后端服务代码 (7个文件,13处修改)
trading-service (Go):
- admin_trade_handler.go: 3处 "for MVP"/"In MVP" 注释清除
- admin_mm_handler.go: 2处 "In MVP"/"for MVP" 注释清除
chain-indexer (Go):
- admin_chain_handler.go: 1处 "for MVP" 注释清除
compliance-service (NestJS):
- admin-compliance.service.ts: 3处 "(mock for MVP)" 注释清除
issuer-service (NestJS):
- admin-issuer.service.ts: 1处 "For MVP" 注释清除
- admin-merchant.service.ts: 2处 "For MVP" 注释清除
notification-service (NestJS):
- event-consumer.service.ts: 1处 "In MVP" 注释清除
### 前端代码 (10个文件)
mobile (5个文件):
- i18n: en/zh_cn/zh_tw/ja 4语言 "MVP版本仅支持" → "当前仅支持"
- i18n key: proMode.mvpNote → proMode.trackNote
- pro_mode_page.dart: 更新key引用
genex-mobile (5个文件):
- 同mobile,4语言+1页面引用全部更新
### 验证结果
全项目grep (?i)\bMVP\b = 0 matches,彻底清除完毕
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:13:47 -08:00
hailin
ad93bc728f
feat: 完成全部后端微服务开发 (10服务/373文件/15586行代码)
...
## 架构概览
- 10个微服务: 7 NestJS + 3 Go/Gin
- DDD + Clean Architecture (Domain/Application/Infrastructure/Interface 四层)
- Kong API Gateway (8080) 统一入口
- PostgreSQL + Redis + Kafka(KRaft) + MinIO 基础设施
## 微服务清单
| 服务 | 技术 | 端口 | 职责 |
|------|------|------|------|
| auth-service | NestJS | 3010 | JWT双Token认证(15min+7d)、注册/登录/刷新/登出 |
| user-service | NestJS | 3001 | 用户Profile、KYC审核、钱包(充值/提现)、消息 |
| issuer-service | NestJS | 3002 | 发行方入驻、券CRUD/搜索/购买、定价引擎、信用评分 |
| trading-service | Go/Gin | 3003 | 撮合引擎(价格-时间优先)、订单簿、做市商API |
| clearing-service | NestJS | 3004 | 交易结算、退款、Breakage、ASC 606会计分录 |
| compliance-service | NestJS | 3005 | AML(5模式)、OFAC筛查、Travel Rule、SAR报告 |
| ai-service | NestJS | 3006 | ACL反腐败层→外部AI Agent集群(含本地降级) |
| translate-service | Go/Gin | 3007 | 区块链地址映射翻译 |
| notification-service | NestJS | 3008 | 推送/短信/邮件/站内通知、事件消费 |
| chain-indexer | Go/Gin | 3009 | 区块链索引器(Mock) |
## Admin API (18个管理模块)
覆盖admin-web全部18+页面:
Dashboard、用户管理、系统管理、用户分析、发行方管理、券管理、
券分析、商户核销、交易监控、做市商管理、财务管理、报表中心、
风控中心、合规审计、争议处理、保险理赔、AI Agent面板、通知管理
## 数据库
- 31个SQL迁移 (000-031) + 种子数据
- 乐观锁(@VersionColumn) + 悲观锁(SELECT FOR UPDATE) + Redis分布式锁
- Outbox Pattern保证消息可靠投递 + 24h幂等窗口
## 共享包
- @genex/common: Guards/Decorators/DTOs/Outbox/Health/Locking/AI-Client
- @genex/kafka-client: 生产者/消费者/Topic定义/KRaft集群支持
## 部署与测试
- docker-compose.yml: 全栈一键启动
- Swagger文档: 7个NestJS服务 /docs 端点
- E2E测试脚本: scripts/run-e2e.sh (Auth→Profile→Wallet→Trading→Admin)
- 迁移脚本: scripts/migrate.sh + scripts/test-setup.sh
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:09:12 -08:00