feat: 配置扩展与 PostgreSQL 连接池 #93

Merged
huanghaosheng merged 4 commits from feature/user-model-phase1 into develop 2026-06-14 16:50:25 +08:00

4 Commits

Author SHA1 Message Date
hhs
0ff810a297 feat: main.go 条件初始化 PostgreSQL 连接池
- 添加 store 包导入
- 当 storage.driver 为 postgres 时创建 pgxpool
- 使用 defer 确保连接池正确关闭
- 添加日志记录连接状态
2026-06-14 16:43:07 +08:00
hhs
bf1e24453c feat: 编写用户表 schema 迁移脚本
- 新增 migrations/001_users.up.sql:创建 users 表和 refresh_tokens 表
- 新增 migrations/001_users.down.sql:回滚脚本
- users 表包含 id, username, password_hash, created_at, updated_at
- refresh_tokens 表包含 id, user_id, token_hash, expires_at, created_at
- 添加必要的索引优化查询性能
2026-06-14 16:42:12 +08:00
hhs
0edafbbf8a feat: 实现 PostgreSQL 连接池
- 新增 internal/store/db.go
- 实现 NewPostgresPool(ctx, dsn) 创建连接池
- 添加 pgx/v5 依赖
- 最大连接数设置为 10
2026-06-14 16:41:50 +08:00
hhs
4b30e67c2e feat: 扩展 Config 结构体,新增 AuthConfig 配置
- 新增 AuthConfig 结构体(JWTSecret, AccessTTL, RefreshTTL)
- 在 Config 中添加 Auth 字段
- 设置默认值:access_ttl=15分钟,refresh_ttl=10080分钟(7天)
- JWTSecret 必须通过环境变量 CAMTALK_AUTH_JWT_SECRET 设置
2026-06-14 16:40:06 +08:00