30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// Achievement 成就徽章
|
|
type Achievement struct {
|
|
ID string `gorm:"primaryKey;type:varchar(50)" json:"id"`
|
|
Name string `gorm:"type:varchar(100);not null" json:"name"`
|
|
Description *string `gorm:"type:varchar(200)" json:"description,omitempty"`
|
|
Icon *string `gorm:"type:varchar(50)" json:"icon,omitempty"`
|
|
Rarity string `gorm:"default:bronze;type:varchar(20)" json:"rarity"`
|
|
Condition *string `gorm:"type:varchar(200)" json:"condition,omitempty"`
|
|
|
|
Users []UserAchievement `gorm:"foreignKey:AchievementID" json:"-"`
|
|
}
|
|
|
|
func (Achievement) TableName() string { return "achievements" }
|
|
|
|
// UserAchievement 用户成就关联
|
|
type UserAchievement struct {
|
|
UserID string `gorm:"column:user_id;type:varchar(32);not null;primaryKey"`
|
|
AchievementID string `gorm:"column:achievement_id;type:varchar(50);not null;primaryKey"`
|
|
UnlockedAt time.Time `gorm:"column:unlocked_at"`
|
|
|
|
User User `gorm:"foreignKey:UserID" json:"-"`
|
|
Achievement Achievement `gorm:"foreignKey:AchievementID" json:"-"`
|
|
}
|
|
|
|
func (UserAchievement) TableName() string { return "user_achievements" }
|