feat: 新增路由配置、交易处理和用户连击功能,并初始化相关服务与处理器

This commit is contained in:
2026-01-28 10:08:48 +08:00
parent 4d024eba8e
commit e811256d99
7 changed files with 508 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
package models
import (
"time"
)
// UserStreak represents a user's consecutive recording streak
type UserStreak struct {
ID uint `gorm:"primarykey" json:"id"`
UserID uint `gorm:"uniqueIndex;not null" json:"user_id"`
CurrentStreak int `gorm:"default:0" json:"current_streak"` // 当前连续天数
LongestStreak int `gorm:"default:0" json:"longest_streak"` // 最长连续记录
LastRecordDate *time.Time `gorm:"type:date" json:"last_record_date"` // 最后记账日期
TotalRecordDays int `gorm:"default:0" json:"total_record_days"` // 累计记账天数
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// TableName specifies the table name for UserStreak
func (UserStreak) TableName() string {
return "user_streaks"
}
// StreakInfo represents the streak information returned to frontend
type StreakInfo struct {
CurrentStreak int `json:"current_streak"` // 当前连续天数
LongestStreak int `json:"longest_streak"` // 最长连续记录
TotalRecordDays int `json:"total_record_days"` // 累计记账天数
HasRecordToday bool `json:"has_record_today"` // 今天是否已记账
Message string `json:"message"` // 提示信息
}