34 lines
1.4 KiB
Go
34 lines
1.4 KiB
Go
// Package user_auth 定义用户端认证接口(登录/刷新),路由前缀 /api。
|
||
package user_auth
|
||
|
||
import "github.com/gogf/gf/v2/frame/g"
|
||
|
||
// LoginReq 用户登录请求(支持微信/手机验证码/账号密码三种方式)。
|
||
type LoginReq struct {
|
||
g.Meta `path:"/auth/login" method:"post" tags:"User/Auth" summary:"用户登录"`
|
||
LoginType string `json:"loginType" v:"required|in:wechat,mobile,password#login type required|unsupported login type"`
|
||
Code string `json:"code"` // 微信授权码
|
||
Mobile string `json:"mobile"` // 手机号(mobile 登录方式)
|
||
VerifyCode string `json:"verifyCode"` // 短信验证码
|
||
Account string `json:"account"` // 账号(password 登录方式)
|
||
Password string `json:"password"` // 密码
|
||
Terminal string `json:"terminal" v:"required|in:mini,h5,app#terminal required|invalid terminal"`
|
||
}
|
||
|
||
// LoginRes 用户登录响应。
|
||
type LoginRes struct {
|
||
AccessToken string `json:"accessToken"`
|
||
RefreshToken string `json:"refreshToken"`
|
||
ExpiresIn int64 `json:"expiresIn"`
|
||
UserID uint64 `json:"userId"`
|
||
}
|
||
|
||
// RefreshReq 使用刷新令牌轮换用户令牌对。
|
||
type RefreshReq struct {
|
||
g.Meta `path:"/auth/refresh" method:"post" tags:"User/Auth" summary:"轮换用户令牌"`
|
||
RefreshToken string `json:"refreshToken" v:"required"`
|
||
}
|
||
|
||
// RefreshRes 是 RefreshReq 的响应。
|
||
type RefreshRes LoginRes
|