- Updated main.go to initialize email service and include it in the dependency injection container. - Refactored handlers to utilize context in service method calls, improving consistency and error handling. - Introduced new service options for upload, security, and captcha services, enhancing modularity and testability. - Removed unused repository implementations to streamline the codebase. This commit continues the effort to improve the architecture by ensuring all services are properly injected and utilized across the application.
67 lines
3.2 KiB
Go
67 lines
3.2 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Profile Minecraft 档案模型
|
|
type Profile struct {
|
|
UUID string `gorm:"column:uuid;type:varchar(36);primaryKey" json:"uuid"`
|
|
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"`
|
|
RSAPrivateKey string `gorm:"column:rsa_private_key;type:text;not null" json:"-"` // RSA 私钥不返回给前端
|
|
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"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
|
|
|
// 关联
|
|
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"`
|
|
}
|
|
|
|
// 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 {
|
|
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"`
|
|
}
|