hailin
ab23270863
chore(identity): add migration for email field and email_codes table
...
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:23:36 -08:00
hailin
a38aac5581
feat(email): 实现邮箱绑定/解绑功能
...
后端:
- 新增 EmailService 邮件发送服务,支持 Gmail SMTP
- 新增 EmailCode 数据模型用于存储邮箱验证码
- UserAccount 添加 email 字段
- 新增 API 接口:
- GET /user/email-status 获取邮箱绑定状态
- POST /user/send-email-code 发送邮箱验证码
- POST /user/bind-email 绑定邮箱
- POST /user/unbind-email 解绑邮箱
- 新增 DTOs: SendEmailCodeDto, BindEmailDto, UnbindEmailDto
- 新增 Commands: SendEmailCodeCommand, BindEmailCommand, UnbindEmailCommand
前端:
- account_service 新增邮箱相关方法和 EmailStatus 类
- bind_email_page 更新为使用真实 API:
- 绑定/更换邮箱功能
- 独立的解绑验证码输入和倒计时
- 解绑确认对话框
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 20:53:20 -08:00
hailin
9b9427d6a8
fix(identity-service): 修复 seed 脚本会清除所有用户数据的严重 bug
...
问题:每次部署 identity-service 时,seed 脚本会执行 deleteMany() 删除所有用户数据
修复:
- 检查现有用户数量,如果 > 5 则跳过 seed(保护生产数据)
- 移除所有 deleteMany() 调用
- 使用 upsert 确保系统账户存在而不是先删后建
- 管理员账户只在不存在时创建
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 03:28:59 -08:00
hailin
0220650cd9
fix(identity-service): 种子用户序列号改为 D25129999999
...
避免与真实用户序列号冲突
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 23:36:54 -08:00
hailin
36f8ee1d6a
fix: SEED01用户状态改为ACTIVE
...
- SYSTEM状态会被识别为冻结账户
- 必须是ACTIVE才能作为有效推荐人
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:52:06 -08:00
hailin
a533987013
fix: SEED01用户accountSequence改为D25122100000格式
...
- identity-service: S0000000005 -> D25122100000
- referral-service: S0000000005 -> D25122100000
- 种子用户序号0,真实用户从1开始
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 17:35:01 -08:00
hailin
6039bffa73
fix: 修改种子用户推荐码为SEED01(6字符)
...
生产环境的ReferralCode值对象限制推荐码必须恰好6个字符,
GENESIS(7字符)不符合格式要求,改为SEED01
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 06:05:45 -08:00
hailin
c58cc351d0
feat: 添加 GENESIS 系统种子用户用于初始推荐码
...
- 在 identity-service 中添加 GENESIS 用户 (userId=5, code=GENESIS)
- 创建 referral-service seed.ts 同步 GENESIS 推荐关系
- 新用户注册时可使用 GENESIS 推荐码进行注册
- GENESIS 用户作为根节点,便于追踪无推荐人的用户
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 04:09:39 -08:00
hailin
7d6e776e5e
refactor: 清理 migration 和 seed 数据重复定义
...
Migration 职责:
- 只负责表结构(CREATE TABLE、索引、外键)
- 设置 user_id 序列从 10 开始(预留 1-9 给系统)
- 移除 GENESIS 用户插入(数据应由 seed 管理)
Seed 职责:
- 恢复到前天状态,移除重复的 GENESIS 定义
- 保留 4 个系统账户(ID 1-4)
- 保留管理员账户初始化
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 00:43:28 -08:00
hailin
37f2b556e9
refactor: 合并 identity-service migrations 为单一 init
...
将 7 个碎片化的 migration 文件合并为一个完整的 init migration:
- 删除增量 migrations (add_user_totp, add_outbox_events, add_password_hash 等)
- 创建统一的 20241204000000_init migration 包含所有表结构
- 包含所有索引、外键约束、序列设置和系统种子用户
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 00:32:58 -08:00
hailin
7a6d8adcb5
fix: 在 seed 中添加 GENESIS 系统种子用户
...
问题原因:
- seed.ts 会删除所有 userAccount 记录
- 即使 migration 创建了 GENESIS 用户,seed 运行后也会被删除
- 之前的系统账户使用 userId 1-4,但 GENESIS 应该是 userId 1
解决方案:
- 将 GENESIS 用户添加到 SYSTEM_ACCOUNTS 数组
- userId: 1, accountSequence: 'SYSTEM00001', referralCode: 'GENESIS'
- 其他系统账户的 userId 顺延到 2-5
系统账户列表:
- userId 1: GENESIS (系统种子用户,用于注册推荐码)
- userId 2: 总部社区 (HQ000001)
- userId 3: 成本费账户 (COST0002)
- userId 4: 运营费账户 (OPER0003)
- userId 5: RWAD底池账户 (POOL0004)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 23:44:15 -08:00
hailin
5fcaeb8794
fix: 恢复 GENESIS 种子用户 migration(正确版本)
...
- 之前误删了 migration 文件
- 重新创建正确的 migration(不包含 created_at 列)
- 添加启动时自动处理失败 migration 的机制
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 22:08:37 -08:00
hailin
0c94b966b0
fix(identity-service): 修复 GENESIS 种子用户 migration - 移除不存在的 created_at 列
...
- 修复 migration 失败问题:user_accounts 表只有 registered_at 和 updated_at,没有 created_at
- 保持 user_id = 1 用于系统种子用户(GENESIS 推荐码)
- 普通用户从 user_id = 10 开始
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 21:18:57 -08:00
hailin
ac8eb6d38d
fix: 修复系统种子用户 migration,移除错误的序列重置
...
问题:
- 之前的 migration (20251220000000) 已经预留了 user_id 1-9 给系统账号
- 并设置序列从 10 开始
- 不应该再次重置序列,否则会覆盖之前的设置
修复:
- 保留使用 user_id = 1(在预留范围内)
- 移除序列重置代码
- 添加注释说明与之前 migration 的关系
这样确保:
✅ 系统账号使用 1-9
✅ 普通用户从 10 开始(之前的设置)
✅ 不会产生 ID 冲突
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 21:01:34 -08:00
hailin
9fd5d1d17d
feat: 添加系统种子用户 migration (推荐码: GENESIS)
...
## 目的
解决"第一个用户无法注册"的问题,通过创建系统种子用户提供根推荐码。
## 种子用户信息
- User ID: 1 (固定ID)
- Account Sequence: SYSTEM00001
- 推荐码: GENESIS
- 昵称: 系统
- 状态: ACTIVE
- 手机号: NULL (系统用户不需要手机号)
## 使用方式
第一批用户在注册时使用推荐码 **GENESIS** 即可完成注册。
## 特点
✅ 保持推荐码必填的业务逻辑
✅ 所有用户都有完整的推荐关系链
✅ 系统用户只提供推荐码功能,不参与其他业务
✅ 使用固定 ID,方便识别和管理
✅ 自动重置序列,确保后续用户从 100000000 开始
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 20:57:34 -08:00
hailin
3f904ab6f7
fix(identity-service): 设置 user_id 自增序列从 10 开始
...
- 添加数据库 migration 设置 user_id 序列起始值为 10
- 保留 user_id 1-9 给系统账户使用
- 修复用户注册时的唯一约束冲突错误
- 序列值安全检查:仅在当前值 < 10 时重置
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 18:16:08 -08:00
hailin
cb40463521
feat(identity-service): 添加管理员登录功能
...
- 新增 AdminAccount 数据表存储管理员账户
- 在 AuthController 添加 POST /auth/login 端点
- 支持邮箱+密码登录,使用 bcrypt 验证
- 在 seed.ts 中初始化默认管理员账户
- 邮箱: admin@rwadurian.com
- 密码: Admin@123456
- 前端登录页面适配新的响应格式
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 05:17:50 -08:00
hailin
9452d14962
feat(identity-service): 添加密码设置和短信验证功能
...
- 添加 bcrypt 依赖用于密码哈希
- 添加 passwordHash 字段到 UserAccount 模型
- 添加 VerifySmsCodeCommand 和 SetPasswordCommand
- 添加 VerifySmsCodeDto 和 SetPasswordDto
- 添加数据库迁移 add_password_hash
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 03:23:36 -08:00
hailin
05a9ca31f6
feat(identity): 实现 Outbox 模式事件发布
...
## 概述
为 identity-service 实现 Outbox 模式,确保数据库事务和 Kafka 事件发布的原子性。
## 新增表
- OutboxEvent: 事件暂存表,用于事务性事件发布
## 新增组件
- OutboxRepository: Outbox 事件持久化
- OutboxPublisherService: 轮询发布未处理事件到 Kafka
## 支持的事件
- identity.UserAccountCreated: 用户注册事件
- identity.UserAccountAutoCreated: 自动创建用户事件
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 00:29:40 -08:00
hailin
579e8c241e
fix(backend): 修复构建错误并添加 TOTP 数据库迁移
...
修复内容:
- identity-service: 添加 CurrentUserPayload 接口定义
- identity-service: 添加 user_totp 表的数据库迁移文件
- wallet-service: 安装 axios 依赖
- wallet-service: 修复 withdrawal-status.handler.ts 中的类型错误
- userId.toString() → userId.value (BigInt 类型)
- unfreezeUsdt() → unfreeze() (正确的方法名)
- amount.asNumber → amount.value (Money 值对象属性)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 05:29:29 -08:00
hailin
b01277ab7d
feat(withdraw): 实现完整的提取功能 - TOTP验证和KAVA转账
...
功能实现:
- identity-service: 添加TOTP二次验证功能
- 新增 UserTotp 数据模型
- 实现 TotpService (生成/验证/启用/禁用)
- 添加 /totp/* API端点
- wallet-service: 提取API添加TOTP验证
- withdrawal.dto 添加可选 totpCode 字段
- 添加 IdentityClientService 调用identity-service验证TOTP
- 添加 WithdrawalStatusHandler 处理区块链确认/失败事件
- blockchain-service: 实现真实KAVA ERC20转账
- 新增 Erc20TransferService (热钱包USDT转账)
- 更新 withdrawal-requested.handler 执行真实转账
- 发布确认/失败事件回wallet-service
- 前端: 对接真实提取API
- withdraw_confirm_page 调用 walletService.withdrawUsdt
环境变量配置:
- TOTP_ENCRYPTION_KEY (identity-service)
- IDENTITY_SERVICE_URL (wallet-service)
- HOT_WALLET_PRIVATE_KEY (blockchain-service)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 05:16:42 -08:00
hailin
75c49951b7
fix: 修复多个服务的 accountSequence 类型和推荐关系 bug
...
1. referral-service: 修复 userId 从临时值 0 导致的 "用户ID必须大于0" 错误
- 从 accountSequence 提取数值部分作为 userId (去掉 "D" 前缀)
- 避免依赖 identity-service 发送的临时 userId
2. 多服务 migration 修复: accountSequence/inviterSequence 类型从 BIGINT 改为 VARCHAR(12)
- identity-service: account_sequence, inviter_sequence
- authorization-service: account_sequence
- blockchain-service: account_sequence
- referral-service: account_sequence
- reward-service: account_sequence
- backup-service: account_sequence
3. mpc-service 与 backup-service 集成:
- mpc-service: 添加 BACKUP_SERVICE_URL, BACKUP_SERVICE_ENABLED, SERVICE_JWT_SECRET
- backup-service: ALLOWED_SERVICES 添加 mpc-service
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 12:29:11 -08:00
hailin
4be9c1fb82
refactor!: 重构账户序列号格式 (BREAKING CHANGE)
...
将 accountSequence 从数字类型改为字符串类型,新格式为:
- 普通用户: D + YYMMDD + 5位序号 (例: D2512120001)
- 系统账户: S + 10位序号 (例: S0000000001)
主要变更:
- identity-service: AccountSequence 值对象改为字符串类型
- identity-service: 序列号生成器改为按日期重置计数
- 所有服务: Prisma schema 字段类型从 BigInt/Int 改为 String
- 所有服务: DTO、Command、Event 中的类型定义更新
- Flutter 前端: 相关数据模型类型更新
涉及服务:
- identity-service (核心变更)
- referral-service
- authorization-service
- wallet-service
- reward-service
- blockchain-service
- backup-service
- planting-service
- mpc-service
- admin-service
- mobile-app (Flutter)
注意: 此为破坏性变更,需要清空数据库并重新运行 migration
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 09:11:18 -08:00
hailin
43016e9ee8
fix(prisma): remove redundant migrations and duplicate indexes
...
- mpc-service: remove duplicate index idx_ms_username on mpc_shares.username
(keep only unique index uq_ms_username since username is unique)
- identity-service: remove redundant migration 20241206000000_add_device_hardware_info
(fields already exist in initial migration 20241204000000_init)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 07:08:24 -08:00
hailin
c1670d2439
feat(mnemonic): add recovery mnemonic generation and backup confirmation
...
Backend (blockchain-service):
- Add RecoveryMnemonicAdapter to generate 12-word BIP39 mnemonic
- Generate mnemonic when wallet addresses are derived (linked to public key)
- Include mnemonic in WalletAddressCreated event
Backend (identity-service):
- Add RecoveryMnemonic table with revocation/replacement support
- Save encrypted mnemonic to database on WalletAddressCreated event
- Add PUT /user/mnemonic/backup API to mark mnemonic as backed up
- Clear plaintext mnemonic from Redis after backup confirmation
Frontend (mobile-app):
- Update markMnemonicBackedUp() to call backend API
- Fix verify_mnemonic_page validation logic:
- Checkbox checked → pass directly
- Not checked → must select correct word
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 12:32:10 -08:00
hailin
8e9eb0ef19
fix(identity): add device_info columns to user_devices migration
...
- Add device_info JSONB column for storing complete device info
- Add platform, device_model, os_version, app_version columns
- Add screen_width, screen_height, locale, timezone columns
- Add idx_platform index
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:42:55 -08:00
hailin
79345a20cf
fix(identity): update migration to TEXT avatar and remove province/city/address
...
- Change avatar_url column from VARCHAR(500) to TEXT
- Remove province_code, city_code, address columns from user_accounts
- Remove idx_province_city index
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:28:09 -08:00
hailin
2705812826
refactor(identity): remove province/city/address fields
...
- Remove provinceCode, cityCode, address from UserAccount aggregate
- Remove ProvinceCode, CityCode value objects
- Remove UserLocationUpdatedEvent domain event
- Update Prisma schema to drop province/city/address columns
- Update repository, mapper, handlers, services and DTOs
- Clean up tests and factory files
Province/city should belong to adoption-service as transaction data,
not identity-service user data.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:23:26 -08:00
hailin
fbec0b9112
feat(identity): store complete deviceInfo JSON from frontend
...
- Add deviceInfo JSON field to UserDevice table (Prisma schema)
- Update DeviceInfo value object to use deviceInfo instead of HardwareInfo
- Update repository to save complete JSON with redundant fields for queries
- Update mapper to read deviceInfo from database
- Update aggregate and handlers to pass deviceInfo through
- Allow any fields in DeviceNameInput interface with index signature
100% preserve original device info JSON from frontend without extraction
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:08:37 -08:00
hailin
657b66c9e5
fix: 修复钱包API路径和avatarUrl字段长度问题
...
- identity-service: avatarUrl字段从VarChar(2000)改为Text类型
- mobile-app: 修复getWalletInfo API路径从/user/$id/wallet改为/user/wallet
- mobile-app: 添加userWallet端点常量
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 10:53:40 -08:00
hailin
51be55d315
feat(reward): 补全10种认种奖励分配规则
...
新增4种系统费用类权益:
- COST_FEE: 成本费 400 USDT → 成本账户(userId=2)
- OPERATION_FEE: 运营费 300 USDT → 运营账户(userId=3)
- HEADQUARTERS_BASE_FEE: 总部社区基础费 9 USDT → 总部社区(userId=1)
- RWAD_POOL_INJECTION: RWAD底池注入 800 USDT → 底池账户(userId=4)
原有6种用户权益类保持不变:
- SHARE_RIGHT: 分享权益 500 USDT
- PROVINCE_AREA_RIGHT: 省区域权益 15 USDT + 1%算力
- PROVINCE_TEAM_RIGHT: 省团队权益 20 USDT
- CITY_AREA_RIGHT: 市区域权益 35 USDT + 2%算力
- CITY_TEAM_RIGHT: 市团队权益 40 USDT
- COMMUNITY_RIGHT: 社区权益 80 USDT
总计: 400 + 300 + 9 + 800 + 500 + 15 + 20 + 35 + 40 + 80 = 2199 USDT
同时更新seed脚本创建4个系统账户
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 09:19:20 -08:00
hailin
742cc21395
fix(identity-service): extend avatar_url column to 2000 chars
...
SVG avatars can be up to 745+ characters, exceeding the previous 500 char limit.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 01:31:44 -08:00
hailin
39804aa981
fix(mobile-app): update share link domain to rwaapi.szaiai.com
...
Changed invite share URLs from rwa-durian.app to rwaapi.szaiai.com
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 21:15:55 -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
b8aa44bf74
feat(identity-service): 添加 Prisma 初始化迁移
...
添加数据库表结构迁移文件:
- user_accounts: 用户账户表
- user_devices: 用户设备表
- wallet_addresses: 钱包地址表
- account_sequence_generator: 账号序列生成器
- user_events: 用户事件表
- device_tokens: 设备令牌表
- dead_letter_events: 死信事件表
- sms_codes: 短信验证码表
- mpc_key_shares: MPC密钥分片表
- mpc_sessions: MPC会话表
- referral_links: 推荐链接表
执行方式: ./deploy.sh migrate
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 16:41:59 -08:00
Developer
a966d71fa0
.
2025-11-30 06:44:57 -08:00
Developer
083db83c96
.
2025-11-29 19:22:42 -08:00
hailin
77725bd769
.
2025-11-24 02:33:14 -08:00
hailin
8e3aa0e794
.
2025-11-24 02:29:44 -08:00
hailin
8f639273b1
.
2025-11-24 01:41:54 -08:00
hailin
ef1ef8ba25
.
2025-11-24 08:27:36 +00:00
hailin
e2055483db
.
2025-11-24 07:25:33 +00:00
hailin
44d2e2ad80
.
2025-11-24 06:58:46 +00:00
hailin
c29c185a03
identity_service_context first commit
2025-11-24 06:09:06 +00:00