- User 模型增加 exp 字段,等级规则 Lv0-Lv6 - 新增签到记录(UserCheckIn)与任务记录(UserTask)模型,唯一索引防重 - 自动签到:AuthMiddleware 验证会话后,基于 Asia/Shanghai 自然日自动签到 +5 经验 - 手动签到:下拉菜单"签到"按钮兜底,已签到显示"今日已签到"并禁用 - 首次任务经验:上传头像/设置用户名/设置个性签名各 +10,审核通过与直接更新均触发 - 经验值变动后自动比对等级,升级时通过通知系统发送"恭喜提升至 LvX" - 下拉菜单重构:顶部头像+用户名+LvX 等级标签,菜单项增加左侧图标,优化布局样式 - 新增 API:POST /api/level/checkin、GET /api/level/info
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package model
|
|
|
|
// 消息/通知类型常量
|
|
const (
|
|
NotifyAuditApproved = "audit_approved"
|
|
NotifyAuditRejected = "audit_rejected"
|
|
NotifyPostApproved = "post_approved"
|
|
NotifyPostRejected = "post_rejected"
|
|
NotifyLevelUp = "level_up"
|
|
)
|
|
|
|
// Notification 消息/通知模型
|
|
type Notification struct {
|
|
BaseModel
|
|
|
|
UserID uint `gorm:"index:idx_user_read,priority:1;not null" json:"user_id"`
|
|
NotifyType string `gorm:"type:varchar(30);index;not null" json:"notify_type"`
|
|
Title string `gorm:"type:varchar(200);not null" json:"title"`
|
|
Content string `gorm:"type:text" json:"content"`
|
|
IsRead bool `gorm:"index:idx_user_read,priority:2;default:false;not null" json:"is_read"`
|
|
RelatedID *uint `gorm:"default:null" json:"related_id,omitempty"` // 关联业务 ID
|
|
}
|
|
|
|
// NotifyTypeNames 通知类型 → 中文名
|
|
var NotifyTypeNames = map[string]string{
|
|
NotifyAuditApproved: "资料审核",
|
|
NotifyAuditRejected: "资料审核",
|
|
NotifyPostApproved: "稿件审核",
|
|
NotifyPostRejected: "稿件审核",
|
|
NotifyLevelUp: "等级提升",
|
|
}
|
|
|
|
// NotificationListResult 消息列表查询结果
|
|
type NotificationListResult struct {
|
|
Items []Notification `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
TotalPages int `json:"total_pages"`
|
|
Unread int64 `json:"unread"`
|
|
}
|