Files
backend_v2/internal/dto/auth.go
toom1996 f4f6e02e3c update
2026-08-31 19:59:56 +08:00

38 lines
1.0 KiB
Go

package dto
// ---------- 响应 ----------
// UserPayload 对外返回的用户信息,绝不包含密码哈希。
type UserPayload struct {
ID uint32 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
}
// ---------- 登录 ----------
// 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"`
}