You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.5 KiB
77 lines
2.5 KiB
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"` |
|
ClientIP string `json:"client_ip"` // 客户端IP地址 |
|
} |
|
|
|
// 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"` |
|
ForceChangePassword bool `json:"force_change_password"` // 是否需要强制修改密码 |
|
} |
|
|
|
// UserInfo 用户信息(登录后返回) |
|
type UserInfo struct { |
|
ID uint `json:"id"` |
|
Username string `json:"username"` |
|
Email string `json:"email"` |
|
Phone string `json:"phone"` |
|
Status int `json:"status"` |
|
CreatedAt time.Time `json:"created_at"` |
|
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"` |
|
Description string `json:"description"` |
|
Permissions []PermissionInfo `json:"permissions"` |
|
} |
|
|
|
// PermissionInfo 权限信息 |
|
type PermissionInfo struct { |
|
ID uint `json:"id"` |
|
Name string `json:"name"` |
|
Description string `json:"description"` |
|
Resource string `json:"resource"` |
|
Action string `json:"action"` |
|
} |
|
|
|
// 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"` |
|
} |
|
|
|
// PasswordStatus 密码状态 |
|
type PasswordStatus struct { |
|
ForceChangePassword bool `json:"force_change_password"` |
|
PasswordExpired bool `json:"password_expired"` |
|
PasswordChangedAt *time.Time `json:"password_changed_at,omitempty"` |
|
}
|
|
|