fd097729d7
- 成就系统、连续打卡天数计算、管理后台成就 CRUD - 梦想目标图标预设 DreamPreset 与用户端 dream-presets 接口 - 管理后台梦想图标 CRUD;戒烟打卡 summary 修正 - 忽略根目录编译产物 /api Made-with: Cursor
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package achievement
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Theme struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
Name string `gorm:"size:50;not null;comment:主题名称" json:"name"`
|
|
Key string `gorm:"size:50;uniqueIndex;not null;comment:主题标识" json:"key"`
|
|
Icon string `gorm:"size:255;comment:主题图标" json:"icon"`
|
|
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
|
IsActive bool `gorm:"default:true;comment:是否启用" json:"is_active"`
|
|
|
|
Levels []Level `gorm:"foreignKey:ThemeID" json:"levels,omitempty"`
|
|
}
|
|
|
|
func (Theme) TableName() string {
|
|
return "fa_achievement_theme"
|
|
}
|
|
|
|
type Level struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
ThemeID uint `gorm:"index;not null;comment:主题ID" json:"theme_id"`
|
|
Name string `gorm:"size:50;not null;comment:等级名称" json:"name"`
|
|
Icon string `gorm:"size:255;comment:等级图标" json:"icon"`
|
|
RequiredDays int `gorm:"not null;default:0;comment:所需打卡天数" json:"required_days"`
|
|
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
|
}
|
|
|
|
func (Level) TableName() string {
|
|
return "fa_achievement_level"
|
|
}
|