224 lines
10 KiB
Go
224 lines
10 KiB
Go
package types
|
||
|
||
import "time"
|
||
|
||
// BaseResponse 基础响应结构
|
||
type BaseResponse struct {
|
||
Code int `json:"code"`
|
||
Message string `json:"message"`
|
||
Data interface{} `json:"data,omitempty"`
|
||
}
|
||
|
||
// PaginationRequest 分页请求
|
||
type PaginationRequest struct {
|
||
Page int `json:"page" form:"page" binding:"omitempty,min=1"`
|
||
PageSize int `json:"page_size" form:"page_size" binding:"omitempty,min=1,max=100"`
|
||
}
|
||
|
||
// PaginationResponse 分页响应
|
||
type PaginationResponse struct {
|
||
List interface{} `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
TotalPages int `json:"total_pages"`
|
||
}
|
||
|
||
// LoginRequest 登录请求
|
||
type LoginRequest struct {
|
||
Username string `json:"username" binding:"required" example:"testuser"` // 支持用户名或邮箱
|
||
Password string `json:"password" binding:"required,min=6,max=128" example:"password123"`
|
||
}
|
||
|
||
// RegisterRequest 注册请求
|
||
type RegisterRequest struct {
|
||
Username string `json:"username" binding:"required,min=3,max=50" example:"newuser"`
|
||
Email string `json:"email" binding:"required,email" example:"user@example.com"`
|
||
Password string `json:"password" binding:"required,min=6,max=128" example:"password123"`
|
||
VerificationCode string `json:"verification_code" binding:"required,len=6" example:"123456"` // 邮箱验证码
|
||
Avatar string `json:"avatar" binding:"omitempty,url" example:"https://rustfs.example.com/avatars/user_1/avatar.png"` // 可选,用户自定义头像
|
||
}
|
||
|
||
// UpdateUserRequest 更新用户请求
|
||
type UpdateUserRequest struct {
|
||
Avatar string `json:"avatar" binding:"omitempty,url" example:"https://example.com/new-avatar.png"`
|
||
OldPassword string `json:"old_password" binding:"omitempty,min=6,max=128" example:"oldpassword123"` // 修改密码时必需
|
||
NewPassword string `json:"new_password" binding:"omitempty,min=6,max=128" example:"newpassword123"` // 新密码
|
||
}
|
||
|
||
// SendVerificationCodeRequest 发送验证码请求
|
||
type SendVerificationCodeRequest struct {
|
||
Email string `json:"email" binding:"required,email" example:"user@example.com"`
|
||
Type string `json:"type" binding:"required,oneof=register reset_password change_email" example:"register"` // 类型: register/reset_password/change_email
|
||
}
|
||
|
||
// ResetPasswordRequest 重置密码请求
|
||
type ResetPasswordRequest struct {
|
||
Email string `json:"email" binding:"required,email" example:"user@example.com"`
|
||
VerificationCode string `json:"verification_code" binding:"required,len=6" example:"123456"`
|
||
NewPassword string `json:"new_password" binding:"required,min=6,max=128" example:"newpassword123"`
|
||
}
|
||
|
||
// ChangeEmailRequest 更换邮箱请求
|
||
type ChangeEmailRequest struct {
|
||
NewEmail string `json:"new_email" binding:"required,email" example:"newemail@example.com"`
|
||
VerificationCode string `json:"verification_code" binding:"required,len=6" example:"123456"`
|
||
}
|
||
|
||
// GenerateAvatarUploadURLRequest 生成头像上传URL请求
|
||
type GenerateAvatarUploadURLRequest struct {
|
||
FileName string `json:"file_name" binding:"required" example:"avatar.png"`
|
||
}
|
||
|
||
// GenerateAvatarUploadURLResponse 生成头像上传URL响应
|
||
type GenerateAvatarUploadURLResponse struct {
|
||
PostURL string `json:"post_url" example:"https://rustfs.example.com/avatars"`
|
||
FormData map[string]string `json:"form_data"`
|
||
AvatarURL string `json:"avatar_url" example:"https://rustfs.example.com/avatars/user_1/xxx.png"`
|
||
ExpiresIn int `json:"expires_in" example:"900"` // 秒
|
||
}
|
||
|
||
// CreateProfileRequest 创建档案请求
|
||
type CreateProfileRequest struct {
|
||
Name string `json:"name" binding:"required,min=1,max=16" example:"PlayerName"`
|
||
}
|
||
|
||
// UpdateTextureRequest 更新材质请求
|
||
type UpdateTextureRequest struct {
|
||
Name string `json:"name" binding:"omitempty,min=1,max=100" example:"My Skin"`
|
||
Description string `json:"description" binding:"omitempty,max=500" example:"A cool skin"`
|
||
IsPublic *bool `json:"is_public" example:"true"`
|
||
}
|
||
|
||
// GenerateTextureUploadURLRequest 生成材质上传URL请求
|
||
type GenerateTextureUploadURLRequest struct {
|
||
FileName string `json:"file_name" binding:"required" example:"skin.png"`
|
||
TextureType TextureType `json:"texture_type" binding:"required,oneof=SKIN CAPE" example:"SKIN"`
|
||
}
|
||
|
||
// GenerateTextureUploadURLResponse 生成材质上传URL响应
|
||
type GenerateTextureUploadURLResponse struct {
|
||
PostURL string `json:"post_url" example:"https://rustfs.example.com/textures"`
|
||
FormData map[string]string `json:"form_data"`
|
||
TextureURL string `json:"texture_url" example:"https://rustfs.example.com/textures/user_1/skin/xxx.png"`
|
||
ExpiresIn int `json:"expires_in" example:"900"` // 秒
|
||
}
|
||
|
||
// LoginResponse 登录响应
|
||
type LoginResponse struct {
|
||
Token string `json:"token"`
|
||
UserInfo *UserInfo `json:"user_info"`
|
||
}
|
||
|
||
// UserInfo 用户信息
|
||
type UserInfo struct {
|
||
ID int64 `json:"id" example:"1"`
|
||
Username string `json:"username" example:"testuser"`
|
||
Email string `json:"email" example:"test@example.com"`
|
||
Avatar string `json:"avatar" example:"https://example.com/avatar.png"`
|
||
Points int `json:"points" example:"100"`
|
||
Role string `json:"role" example:"user"`
|
||
Status int16 `json:"status" example:"1"`
|
||
LastLoginAt *time.Time `json:"last_login_at,omitempty" example:"2025-10-01T12:00:00Z"`
|
||
CreatedAt time.Time `json:"created_at" example:"2025-10-01T10:00:00Z"`
|
||
UpdatedAt time.Time `json:"updated_at" example:"2025-10-01T10:00:00Z"`
|
||
}
|
||
|
||
// TextureType 材质类型
|
||
type TextureType string
|
||
|
||
const (
|
||
TextureTypeSkin TextureType = "SKIN"
|
||
TextureTypeCape TextureType = "CAPE"
|
||
)
|
||
|
||
// TextureInfo 材质信息
|
||
type TextureInfo struct {
|
||
ID int64 `json:"id" example:"1"`
|
||
UploaderID int64 `json:"uploader_id" example:"1"`
|
||
Name string `json:"name" example:"My Skin"`
|
||
Description string `json:"description,omitempty" example:"A cool skin"`
|
||
Type TextureType `json:"type" example:"SKIN"`
|
||
URL string `json:"url" example:"https://rustfs.example.com/textures/xxx.png"`
|
||
Hash string `json:"hash" example:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"`
|
||
Size int `json:"size" example:"2048"`
|
||
IsPublic bool `json:"is_public" example:"true"`
|
||
DownloadCount int `json:"download_count" example:"100"`
|
||
FavoriteCount int `json:"favorite_count" example:"50"`
|
||
IsSlim bool `json:"is_slim" example:"false"`
|
||
Status int16 `json:"status" example:"1"`
|
||
CreatedAt time.Time `json:"created_at" example:"2025-10-01T10:00:00Z"`
|
||
UpdatedAt time.Time `json:"updated_at" example:"2025-10-01T10:00:00Z"`
|
||
}
|
||
|
||
// ProfileInfo 角色信息
|
||
type ProfileInfo struct {
|
||
UUID string `json:"uuid" example:"550e8400-e29b-41d4-a716-446655440000"`
|
||
UserID int64 `json:"user_id" example:"1"`
|
||
Name string `json:"name" example:"PlayerName"`
|
||
SkinID *int64 `json:"skin_id,omitempty" example:"1"`
|
||
CapeID *int64 `json:"cape_id,omitempty" example:"2"`
|
||
LastUsedAt *time.Time `json:"last_used_at,omitempty" example:"2025-10-01T12:00:00Z"`
|
||
CreatedAt time.Time `json:"created_at" example:"2025-10-01T10:00:00Z"`
|
||
UpdatedAt time.Time `json:"updated_at" example:"2025-10-01T10:00:00Z"`
|
||
}
|
||
|
||
// UploadURLRequest 上传URL请求
|
||
type UploadURLRequest struct {
|
||
Type TextureType `json:"type" binding:"required,oneof=SKIN CAPE"`
|
||
Filename string `json:"filename" binding:"required"`
|
||
}
|
||
|
||
// UploadURLResponse 上传URL响应
|
||
type UploadURLResponse struct {
|
||
PostURL string `json:"post_url"`
|
||
FormData map[string]string `json:"form_data"`
|
||
FileURL string `json:"file_url"`
|
||
ExpiresIn int `json:"expires_in"`
|
||
}
|
||
|
||
// CreateTextureRequest 创建材质请求
|
||
type CreateTextureRequest struct {
|
||
Name string `json:"name" binding:"required,min=1,max=100" example:"My Cool Skin"`
|
||
Description string `json:"description" binding:"max=500" example:"A very cool skin"`
|
||
Type TextureType `json:"type" binding:"required,oneof=SKIN CAPE" example:"SKIN"`
|
||
URL string `json:"url" binding:"required,url" example:"https://rustfs.example.com/textures/user_1/skin/xxx.png"`
|
||
Hash string `json:"hash" binding:"required,len=64" example:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"`
|
||
Size int `json:"size" binding:"required,min=1" example:"2048"`
|
||
IsPublic bool `json:"is_public" example:"true"`
|
||
IsSlim bool `json:"is_slim" example:"false"` // Alex模型(细臂)为true,Steve模型(粗臂)为false
|
||
}
|
||
|
||
// SearchTextureRequest 搜索材质请求
|
||
type SearchTextureRequest struct {
|
||
PaginationRequest
|
||
Keyword string `json:"keyword" form:"keyword"`
|
||
Type TextureType `json:"type" form:"type" binding:"omitempty,oneof=SKIN CAPE"`
|
||
PublicOnly bool `json:"public_only" form:"public_only"`
|
||
}
|
||
|
||
// UpdateProfileRequest 更新角色请求
|
||
type UpdateProfileRequest struct {
|
||
Name string `json:"name" binding:"omitempty,min=1,max=16" example:"NewPlayerName"`
|
||
SkinID *int64 `json:"skin_id,omitempty" example:"1"`
|
||
CapeID *int64 `json:"cape_id,omitempty" example:"2"`
|
||
}
|
||
|
||
// SystemConfigResponse 基础系统配置响应
|
||
type SystemConfigResponse struct {
|
||
SiteName string `json:"site_name" example:"CarrotSkin"`
|
||
SiteDescription string `json:"site_description" example:"A Minecraft Skin Station"`
|
||
RegistrationEnabled bool `json:"registration_enabled" example:"true"`
|
||
MaxTexturesPerUser int `json:"max_textures_per_user" example:"100"`
|
||
MaxProfilesPerUser int `json:"max_profiles_per_user" example:"5"`
|
||
}
|
||
|
||
// RenderResponse 材质渲染响应
|
||
type RenderResponse struct {
|
||
URL string `json:"url" example:"https://rustfs.example.com/renders/xxx.png"`
|
||
ContentType string `json:"content_type" example:"image/png"`
|
||
ETag string `json:"etag,omitempty" example:"abc123def456"`
|
||
Size int64 `json:"size" example:"2048"`
|
||
LastModified *time.Time `json:"last_modified,omitempty" example:"2025-10-01T12:00:00Z"`
|
||
}
|