|
|
|
package model
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
// LoginRequest 登录请求
|
|
|
|
type LoginRequest struct {
|
|
|
|
Username string `json:"username" binding:"required" validate:"required,min=3,max=50"`
|
|
|
|
Password string `json:"password" binding:"required" validate:"required,min=6,max=100"`
|
|
|
|
Captcha string `json:"captcha" binding:"required" validate:"required,len=4"`
|
|
|
|
CaptchaID string `json:"captcha_id" binding:"required" validate:"required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoginResponse 登录响应
|
|
|
|
type LoginResponse struct {
|
|
|
|
Token string `json:"token"`
|
|
|
|
TokenType string `json:"token_type"`
|
|
|
|
ExpiresIn int64 `json:"expires_in"`
|
|
|
|
RefreshToken string `json:"refresh_token"`
|
|
|
|
User UserInfo `json:"user"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserInfo 用户信息(登录后返回)
|
|
|
|
type UserInfo struct {
|
|
|
|
ID uint `json:"id"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Phone string `json:"phone"`
|
|
|
|
Status int `json:"status"`
|
|
|
|
LastLoginAt *time.Time `json:"last_login_at,omitempty"`
|
|
|
|
LastLoginIP string `json:"last_login_ip,omitempty"`
|
|
|
|
Roles []RoleInfo `json:"roles"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RoleInfo 角色信息
|
|
|
|
type RoleInfo struct {
|
|
|
|
ID uint `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Code string `json:"code"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RefreshTokenRequest 刷新令牌请求
|
|
|
|
type RefreshTokenRequest struct {
|
|
|
|
RefreshToken string `json:"refresh_token" binding:"required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// LogoutRequest 登出请求
|
|
|
|
type LogoutRequest struct {
|
|
|
|
Token string `json:"token" binding:"required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// CaptchaResponse 验证码响应
|
|
|
|
type CaptchaResponse struct {
|
|
|
|
CaptchaID string `json:"captcha_id"`
|
|
|
|
CaptchaImage string `json:"captcha_image"` // Base64编码的图片
|
|
|
|
ExpiresIn int64 `json:"expires_in"`
|
|
|
|
}
|