yangjianbo
|
bbd6236385
|
fix(数据库): 补充默认分组种子迁移
确保安装时至少存在一个默认分组
|
2025-12-29 11:48:19 +08:00 |
|
yangjianbo
|
cc4da2ae82
|
fix(数据库): 修复使用记录缓存列命名不一致
新增迁移补齐 cache_creation_5m_tokens/cache_creation_1h_tokens 列,并从旧列回填数据
|
2025-12-29 11:45:07 +08:00 |
|
yangjianbo
|
3a7d3387e0
|
fix(数据库): 修复默认分组缺失与迁移锁阻塞
通过迁移补种默认 groups 记录,避免新装空分组
迁移锁改为 try lock + 重试并加入超时
写入 usage_logs 时保留 rate_multiplier=0 语义
测试: go test ./...
|
2025-12-29 10:43:46 +08:00 |
|
yangjianbo
|
3d617de577
|
refactor(数据库): 迁移持久层到 Ent 并清理 GORM
将仓储层/基础设施改为 Ent + 原生 SQL 执行路径,并移除 AutoMigrate 与 GORM 依赖。
重构内容包括:
- 仓储层改用 Ent/SQL(含 usage_log/account 等复杂查询),统一错误映射
- 基础设施与 setup 初始化切换为 Ent + SQL migrations
- 集成测试与 fixtures 迁移到 Ent 事务模型
- 清理遗留 GORM 模型/依赖,补充迁移与文档说明
- 增加根目录 Makefile 便于前后端编译
测试:
- go test -tags unit ./...
- go test -tags integration ./...
|
2025-12-29 10:03:27 +08:00 |
|
dexcoder6
|
50dba656fd
|
feat: 添加用户余额充值/退款功能 (#17)
## 功能特性
### 前端
- 在用户列表操作列添加充值和退款按钮
- 实现充值/退款对话框,支持输入金额和备注
- 从编辑用户表单中移除余额字段,防止直接修改
- 添加余额不足验证,实时显示操作后余额
- 优化备注提示词,提供多种场景示例
### 后端
- 为 redeem_codes 表添加 notes 字段(迁移文件)
- 在 UpdateUserBalance 接口添加 notes 参数支持
- 添加余额验证:金额必须大于0,操作后余额不能为负
- UpdateUser 接口移除 balance 字段处理,防止误操作
- 完整的审计日志和缓存管理
## 安全保护
- 前端:余额不足时禁用提交按钮,实时提示
- 后端:双重验证(输入金额 > 0 + 结果余额 >= 0)
- 权限:仅管理员可访问(AdminAuth 中间件)
- 审计:所有操作记录到 redeem_codes 表
## 修改文件
后端:
- backend/migrations/004_add_redeem_code_notes.sql
- backend/internal/model/redeem_code.go
- backend/internal/service/admin_service.go
- backend/internal/handler/admin/user_handler.go
前端:
- frontend/src/views/admin/UsersView.vue
- frontend/src/api/admin/users.ts
- frontend/src/i18n/locales/zh.ts
- frontend/src/i18n/locales/en.ts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-23 16:29:57 +08:00 |
|
shaw
|
642842c29e
|
First commit
|
2025-12-18 13:50:39 +08:00 |
|