feat: 实现积分与等级系统 + 签到功能 + 下拉菜单优化

- User 模型增加 exp 字段,等级规则 Lv0-Lv6
- 新增签到记录(UserCheckIn)与任务记录(UserTask)模型,唯一索引防重
- 自动签到:AuthMiddleware 验证会话后,基于 Asia/Shanghai 自然日自动签到 +5 经验
- 手动签到:下拉菜单"签到"按钮兜底,已签到显示"今日已签到"并禁用
- 首次任务经验:上传头像/设置用户名/设置个性签名各 +10,审核通过与直接更新均触发
- 经验值变动后自动比对等级,升级时通过通知系统发送"恭喜提升至 LvX"
- 下拉菜单重构:顶部头像+用户名+LvX 等级标签,菜单项增加左侧图标,优化布局样式
- 新增 API:POST /api/level/checkin、GET /api/level/info
This commit is contained in:
2026-05-31 20:58:14 +08:00
parent 91115447e8
commit fdb636f98f
24 changed files with 663 additions and 32 deletions

View File

@ -1,6 +1,10 @@
package service
import "metazone.cc/metalab/internal/model"
import (
"time"
"metazone.cc/metalab/internal/model"
)
// userAuthStore AuthService 所需的最小仓储接口ISP7 个方法)
type userAuthStore interface {
@ -58,3 +62,26 @@ type postNotifier interface {
NotifyPostApproved(userID uint, postTitle string, postID uint)
NotifyPostRejected(userID uint, postTitle, reason string, postID uint)
}
// userLevelStore LevelService 所需的用户仓储接口
type userLevelStore interface {
FindByID(id uint) (*model.User, error)
AddExp(userID uint, delta int) error
}
// checkInStore 签到记录仓储接口
type checkInStore interface {
FindCheckIn(userID uint, date time.Time) (*model.UserCheckIn, error)
CreateCheckIn(ci *model.UserCheckIn) error
}
// taskStore 任务完成记录仓储接口
type taskStore interface {
FindTask(userID uint, taskType string) (*model.UserTask, error)
CreateTask(task *model.UserTask) error
}
// levelNotifier 等级升级通知接口
type levelNotifier interface {
Create(userID uint, notifyType, title, content string, relatedID *uint) error
}