fix: 域能系统全量检查 — 修复 5 个逻辑/交互 Gap

- 修复 Admin 改名路径未扣域能(非审核路径补充 HasCompletedTask + DeductOnRename)
- 赋能按钮改为 Modal 弹窗(轻赋/重赋选择 + 每日上限提示)
- EnergyInfo API 增加 daily_energize_exp/daily_exp_cap_reached 返回值
- "我的域能" TAB 增加经验值和等级展示
- Energize 事务修复:导出 EnergyStore + WithTx 方法确保 DB 操作原子性
- Studio 写文章页新增 LV0 锁止横幅 + 禁用提交按钮
This commit is contained in:
2026-06-01 12:10:16 +08:00
parent e1d7c318ab
commit 6542d1e055
10 changed files with 325 additions and 44 deletions

View File

@ -4,6 +4,8 @@ import (
"time"
"metazone.cc/metalab/internal/model"
"gorm.io/gorm"
)
// userAuthStore AuthService 所需的最小仓储接口ISP7 个方法)
@ -87,8 +89,8 @@ type levelNotifier interface {
Create(userID uint, notifyType, title, content string, relatedID *uint) error
}
// energyStore EnergyService 所需的完整仓储接口
type energyStore interface {
// EnergyStore EnergyService 所需的完整仓储接口
type EnergyStore interface {
FindUserByID(userID uint) (*model.User, error)
FindPostByID(postID uint) (*model.Post, error)
AddEnergy(userID uint, amount int) error
@ -102,8 +104,13 @@ type energyStore interface {
ListEnergyLogsByUser(userID uint, days int, offset, limit int) ([]model.EnergyLog, error)
CountEnergyLogsByUser(userID uint, days int) (int64, error)
ListAllEnergyLogs(energyType string, offset, limit int) ([]model.EnergyLog, int64, error)
// WithTx 基于给定事务连接创建新的 EnergyStore确保事务内操作原子性
WithTx(tx *gorm.DB) EnergyStore
}
// energyStore 向后兼容别名
type energyStore = EnergyStore
// energyNotifier EnergyService 所需的通知接口ISP
type energyNotifier interface {
Create(userID uint, notifyType, title, content string, relatedID *uint) error