hailin
|
3a57b0fd4d
|
feat: 全平台API对齐 — 4个前端应用55+页面接入真实后端API
跨越 genex-mobile、admin-app、admin-web、miniapp 四个前端应用,
将所有页面从 mock 硬编码数据替换为真实后端 API 调用,
同时补建后端缺失的 27+ 个端点,实现前后端完整联通。
## 后端新增 (4个微服务, 27+端点)
### issuer-service — 5个新Controller, 19个新文件
- IssuerStatsController: GET /issuers/me/stats, /credit (发行商仪表盘统计+信用)
- IssuerFinanceController: GET/POST balance/stats/transactions/withdraw/reconciliation
- IssuerStoreController: CRUD /issuers/me/stores + /employees (门店+员工管理)
- RedemptionController: POST scan/manual/batch, GET history/today-stats (核销)
- CouponBatchController: POST issue/recall/price-adjust, GET operations (批量操作)
- CouponController扩展: GET /search, /:id/nearby-stores, /:id/similar
- 新实体: Employee, Redemption; Store 增加 level/parentId
- 新迁移: 032_create_stores_employees_redemptions.sql
### trading-service (Go)
- GET /api/v1/trades/my/orders — 用户订单列表(分页+状态筛选)
- POST /api/v1/trades/coupons/:id/transfer — 券转赠
### user-service
- GET/PUT /api/v1/users/me/settings — 用户偏好设置(语言/货币/通知)
### auth-service
- POST /api/v1/auth/send-sms-code — 发送短信验证码(Redis存储, 5分钟TTL)
- POST /api/v1/auth/login-phone — 手机号+验证码登录(自动注册)
### Kong 路由
- 新增5条路由: issuers/me, redemptions, coupons/batch, trades/my, trades/coupons
## genex-mobile (Flutter, 2页)
- HomePage: 接入 CouponApiService.getFeaturedCoupons() + getHoldingsSummary()
- WalletCouponsPage: 接入持仓列表API, 支持Tab状态筛选
- 修复 NotificationService/PushService 7+2个路径缺少 /api/v1/ 前缀
- 新增 CouponApiService, CouponModel, HoldingsSummaryModel
## admin-app (Flutter发行商控制台, 11页 + router + i18n)
- 修复 NotificationService 7个路径 + PushService 2个路径前缀
- 新增9个Service: auth, issuer, coupon, finance, credit, store, redemption, analytics, ai_chat
- 11页全部从 StatelessWidget→StatefulWidget, mock→API:
IssuerLoginPage(SMS登录), Dashboard(统计), CouponList(分页+筛选),
CreateCoupon(提交审核), CouponDetail(详情), Redemption(扫码/手动/批量核销),
Finance(余额/流水/对账), Credit(评分), StoreManagement(门店+员工),
AiAgent(真实AI对话), Settings(资料+登出)
- 所有页面添加 loading/error/pull-to-refresh 状态
## admin-web (Next.js 15管理后台, 24页)
- 新建API基础设施: api-client.ts(axios), auth-context.tsx, use-api.ts(react-query)
- providers.tsx 接入 QueryClientProvider + AuthProvider
- 24页全部替换 useState(mockArray) 为 useApi<T>('/api/v1/admin/...'):
Dashboard, Users, Issuers, Coupons, Trading, Risk, Finance, System,
Compliance(SAR/SEC/License/SOX/Tax/IPO), Analytics(User/Coupon/MM/Consumer),
Disputes, Chain, Reports, Merchant, Agent, Insurance
- 所有页面添加 TypeScript 接口, loading/error 状态, 'use client' 指令
- 状态比较改用原始API字符串(非t()翻译值)
## miniapp (Taro/React小程序, 20页)
- 新建API基础设施: config/index.ts, utils/request.ts(Taro.request封装), store/auth.ts
- 新增8个Service: auth, coupon, my-coupon, user, trading, wallet, notification, ai
- 20页全部替换硬编码数据为Service调用:
Home, Search, Detail, Purchase, PaymentSuccess,
MyCoupons, MyCouponDetail, Redeem, Transfer,
Profile, Orders, Messages, Wallet, Settings, KYC, AIChat,
Login, H5Share, H5Activity, H5Register
- 统一 useState+useEffect 数据获取模式, 错误处理, 加载状态
## 统计
- 新建文件: ~51个 (后端26 + 前端25)
- 修改文件: ~93个 (后端24 + 前端69)
- 新增后端端点: 27+
- 前端页面接入API: 55+ (genex-mobile 2 + admin-app 11 + admin-web 24 + miniapp 20)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
2026-02-22 22:53:07 -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 |