196 lines
8.3 KiB
Go
196 lines
8.3 KiB
Go
package types
|
|
|
|
import "time"
|
|
|
|
// BaseResponse 基础响应结构
|
|
// @Description 通用API响应结构
|
|
type BaseResponse struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
|
|
// PaginationRequest 分页请求
|
|
// @Description 分页查询参数
|
|
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 分页响应
|
|
// @Description 分页查询结果
|
|
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 登录请求
|
|
// @Description 用户登录请求参数
|
|
type LoginRequest struct {
|
|
Username string `json:"username" binding:"required" example:"testuser"` // 支持用户名或邮箱
|
|
Password string `json:"password" binding:"required,min=6,max=128" example:"password123"`
|
|
}
|
|
|
|
// RegisterRequest 注册请求
|
|
// @Description 用户注册请求参数
|
|
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 更新用户请求
|
|
// @Description 更新用户信息请求参数
|
|
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 发送验证码请求
|
|
// @Description 发送邮箱验证码请求参数
|
|
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 重置密码请求
|
|
// @Description 重置密码请求参数
|
|
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 更换邮箱请求
|
|
// @Description 更换邮箱请求参数
|
|
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"`
|
|
}
|
|
|
|
// CreateProfileRequest 创建档案请求
|
|
// @Description 创建Minecraft档案请求参数
|
|
type CreateProfileRequest struct {
|
|
Name string `json:"name" binding:"required,min=1,max=16" example:"PlayerName"`
|
|
}
|
|
|
|
// UpdateTextureRequest 更新材质请求
|
|
// @Description 更新材质信息请求参数
|
|
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"`
|
|
}
|
|
|
|
// LoginResponse 登录响应
|
|
// @Description 登录成功响应数据
|
|
type LoginResponse struct {
|
|
Token string `json:"token"`
|
|
UserInfo *UserInfo `json:"user_info"`
|
|
}
|
|
|
|
// UserInfo 用户信息
|
|
// @Description 用户详细信息
|
|
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 材质信息
|
|
// @Description 材质详细信息
|
|
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 角色信息
|
|
// @Description Minecraft档案信息
|
|
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请求
|
|
// @Description 获取材质上传URL请求参数
|
|
type UploadURLRequest struct {
|
|
Type TextureType `json:"type" binding:"required,oneof=SKIN CAPE"`
|
|
Filename string `json:"filename" binding:"required"`
|
|
}
|
|
|
|
// UploadURLResponse 上传URL响应
|
|
// @Description 材质上传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"`
|
|
}
|
|
|
|
// SearchTextureRequest 搜索材质请求
|
|
// @Description 搜索材质请求参数
|
|
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 更新角色请求
|
|
// @Description 更新Minecraft档案请求参数
|
|
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 基础系统配置响应
|
|
// @Description 系统配置信息
|
|
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"`
|
|
}
|