2025-11-28 23:30:49 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Profile Minecraft 档案模型
|
|
|
|
|
type Profile struct {
|
|
|
|
|
UUID string `gorm:"column:uuid;type:varchar(36);primaryKey" json:"uuid"`
|
2025-12-02 10:33:19 +08:00
|
|
|
UserID int64 `gorm:"column:user_id;not null;index:idx_profiles_user_created,priority:1;index:idx_profiles_user_active,priority:1" json:"user_id"`
|
|
|
|
|
Name string `gorm:"column:name;type:varchar(16);not null;uniqueIndex:idx_profiles_name" json:"name"` // Minecraft 角色名
|
|
|
|
|
SkinID *int64 `gorm:"column:skin_id;type:bigint;index:idx_profiles_skin_id" json:"skin_id,omitempty"`
|
|
|
|
|
CapeID *int64 `gorm:"column:cape_id;type:bigint;index:idx_profiles_cape_id" json:"cape_id,omitempty"`
|
2025-11-28 23:30:49 +08:00
|
|
|
RSAPrivateKey string `gorm:"column:rsa_private_key;type:text;not null" json:"-"` // RSA 私钥不返回给前端
|
2025-12-02 10:33:19 +08:00
|
|
|
IsActive bool `gorm:"column:is_active;not null;default:true;index:idx_profiles_user_active,priority:2" json:"is_active"`
|
|
|
|
|
LastUsedAt *time.Time `gorm:"column:last_used_at;type:timestamp;index:idx_profiles_last_used,sort:desc" json:"last_used_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP;index:idx_profiles_user_created,priority:2,sort:desc" json:"created_at"`
|
2025-11-28 23:30:49 +08:00
|
|
|
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
|
|
|
|
|
|
|
|
|
// 关联
|
2025-12-02 10:33:19 +08:00
|
|
|
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"user,omitempty"`
|
|
|
|
|
Skin *Texture `gorm:"foreignKey:SkinID;constraint:OnDelete:SET NULL" json:"skin,omitempty"`
|
|
|
|
|
Cape *Texture `gorm:"foreignKey:CapeID;constraint:OnDelete:SET NULL" json:"cape,omitempty"`
|
2025-11-28 23:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TableName 指定表名
|
|
|
|
|
func (Profile) TableName() string {
|
|
|
|
|
return "profiles"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProfileResponse 档案响应(包含完整的皮肤/披风信息)
|
|
|
|
|
type ProfileResponse struct {
|
|
|
|
|
UUID string `json:"uuid"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Textures ProfileTexturesData `json:"textures"`
|
|
|
|
|
IsActive bool `json:"is_active"`
|
|
|
|
|
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProfileTexturesData Minecraft 材质数据结构
|
|
|
|
|
type ProfileTexturesData struct {
|
|
|
|
|
Skin *ProfileTexture `json:"SKIN,omitempty"`
|
|
|
|
|
Cape *ProfileTexture `json:"CAPE,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProfileTexture 单个材质信息
|
|
|
|
|
type ProfileTexture struct {
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
Metadata *ProfileTextureMetadata `json:"metadata,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProfileTextureMetadata 材质元数据
|
|
|
|
|
type ProfileTextureMetadata struct {
|
|
|
|
|
Model string `json:"model,omitempty"` // "slim" or "classic"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type KeyPair struct {
|
2025-12-02 22:52:33 +08:00
|
|
|
PrivateKey string `json:"private_key" bson:"private_key"`
|
|
|
|
|
PublicKey string `json:"public_key" bson:"public_key"`
|
|
|
|
|
PublicKeySignature string `json:"public_key_signature" bson:"public_key_signature"`
|
|
|
|
|
PublicKeySignatureV2 string `json:"public_key_signature_v2" bson:"public_key_signature_v2"`
|
|
|
|
|
YggdrasilPublicKey string `json:"yggdrasil_public_key" bson:"yggdrasil_public_key"`
|
|
|
|
|
Expiration time.Time `json:"expiration" bson:"expiration"`
|
|
|
|
|
Refresh time.Time `json:"refresh" bson:"refresh"`
|
2025-11-28 23:30:49 +08:00
|
|
|
}
|