gcx/backend/services
hailin e89ec82406 feat(auth): 完整实现 SMS 手机注册/登录/验证系统
参考 rwadurian 项目的成熟实现,在 Genex auth-service 上全面增强短信验证体系。

## 新增功能

### Domain 层
- Phone Value Object: E.164 标准化、中国大陆格式自动补+86、掩码显示(138****8000)
- SmsCode Value Object: crypto 安全随机6位生成、格式验证
- SmsVerification Entity: 验证码记录持久化,支持4种类型(REGISTER/LOGIN/RESET_PASSWORD/CHANGE_PHONE)
- SmsLog Entity: SMS发送日志审计追踪(provider/status/error)
- User Entity 增强: loginFailCount + lockedUntil 字段,指数退避锁定策略(1→2→4→8...→1440分钟)
- 5个新 Domain Events: SmsCodeSent, SmsCodeVerified, AccountLocked, PhoneChanged, PasswordReset

### Infrastructure 层
- 3个 SQL 迁移: users表锁定字段(041), sms_verifications表(042), sms_logs表(043)
- SmsVerification/SmsLog TypeORM Repository 实现
- SMS Provider 抽象层: ISmsProvider 接口 + ConsoleSmsProvider(开发) + AliyunSmsProvider(生产)
- Redis SmsCodeService 增强: 类型前缀 auth:sms:{type}:{phone},保留向后兼容

### Application 层
- 独立 SmsService: 发送验证码(日限额10条+业务规则校验) + 验证验证码(尝试限制5次)
- AuthService 重构: 注册需SMS验证、密码登录带锁定检查、+resetPassword/changePhone

### Interface 层
- 新端点: POST /auth/sms/send, POST /auth/reset-password, POST /auth/change-phone
- DTO 更新: RegisterDto 增加 smsCode 必填, SendSmsCodeDto 增加 type 枚举
- 全部端点 Swagger 文档

### 配置
- .env.example: SMS_ENABLED, ALIYUN_SMS_*, SMS_DAILY_LIMIT, LOGIN_MAX_FAIL_ATTEMPTS
- auth.module: SMS_PROVIDER 按 SMS_ENABLED 环境变量自动切换

## API 端点一览
- POST /api/v1/auth/sms/send — 发送验证码(4种类型)
- POST /api/v1/auth/register — 手机注册(phone+smsCode+password)
- POST /api/v1/auth/login — 密码登录(带锁定检查)
- POST /api/v1/auth/login-phone — 短信验证码登录
- POST /api/v1/auth/reset-password — 重置密码
- POST /api/v1/auth/change-phone — 换绑手机(需登录)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:12:57 -08:00
..
admin-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
ai-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
auth-service feat(auth): 完整实现 SMS 手机注册/登录/验证系统 2026-02-23 19:12:57 -08:00
chain-indexer feat(health): 为全部12个微服务添加Docker健康检查 2026-02-20 05:39:25 -08:00
clearing-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
compliance-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
issuer-service feat: 全平台API对齐 — 4个前端应用55+页面接入真实后端API 2026-02-22 22:53:07 -08:00
notification-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
telemetry-service fix(health): 修正NestJS服务健康检查URL路径 /health → /api/v1/health 2026-02-20 05:50:26 -08:00
trading-service feat: 全平台API对齐 — 4个前端应用55+页面接入真实后端API 2026-02-22 22:53:07 -08:00
translate-service feat(health): 为全部12个微服务添加Docker健康检查 2026-02-20 05:39:25 -08:00
user-service feat: 全平台API对齐 — 4个前端应用55+页面接入真实后端API 2026-02-22 22:53:07 -08:00