Files
backend_v2/internal/dto/auth.go
2026-09-20 01:06:13 +08:00

40 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dto
// ---------- 响应 ----------
// UserPayload 对外返回的用户信息,绝不包含密码哈希。
type UserPayload struct {
ID uint32 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
// Tier 用户等级 free/vip;仅作账号标记,图片质量模型已统一,不再影响图片 URL。
Tier string `json:"tier"`
}
// ---------- 登录 ----------
// LoginRequest 登录请求体。account 支持用户名或邮箱。
type LoginRequest struct {
Account string `json:"account" binding:"required"`
Password string `json:"password" binding:"required"`
}
// LoginResponse 登录成功响应(双令牌)。
type LoginResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"` // access token 有效期(秒)
User UserPayload `json:"user"`
}
// RefreshRequest 续期请求体。
type RefreshRequest struct {
RefreshToken string `json:"refresh_token" binding:"required"`
}
// RefreshResponse 续期成功响应。
type RefreshResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}