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.
91 lines
2.6 KiB
91 lines
2.6 KiB
package vo
|
|
|
|
import (
|
|
"time"
|
|
|
|
"laic-backend/model"
|
|
)
|
|
|
|
// UserLoginReq 登录请求
|
|
type UserLoginReq struct {
|
|
Phone string `json:"phone" validate:"required,phone"`
|
|
Password string `json:"password" validate:"omitempty"`
|
|
Captcha string `json:"captcha" validate:"omitempty,len=4"`
|
|
SmsCode string `json:"smsCode" validate:"omitempty,len=6"`
|
|
}
|
|
|
|
// RegisterReq 注册请求
|
|
type RegisterReq struct {
|
|
Name string `json:"name" validate:"required,max=32"`
|
|
Phone string `json:"phone" validate:"required,phone"`
|
|
Email string `json:"email" validate:"omitempty,email"`
|
|
Password string `json:"password" validate:"required,password"`
|
|
SmsCode string `json:"smsCode" validate:"required,len=6"`
|
|
}
|
|
|
|
// SmsCodeReq 发送短信验证码请求
|
|
type SmsCodeReq struct {
|
|
Phone string `json:"phone" validate:"required,phone"`
|
|
Scene string `json:"scene" validate:"required,oneof=login register reset"`
|
|
}
|
|
|
|
// ResetPasswordReq 重置密码请求
|
|
type ResetPasswordReq struct {
|
|
Phone string `json:"phone" validate:"required,phone"`
|
|
SmsCode string `json:"smsCode" validate:"required"`
|
|
NewPassword string `json:"newPassword" validate:"required,password"`
|
|
}
|
|
|
|
// RefreshReq 刷新 token 请求
|
|
type RefreshReq struct {
|
|
RefreshToken string `json:"refreshToken" validate:"required"`
|
|
}
|
|
|
|
// LogoutReq 登出请求(refreshToken 可选,用于同时注销刷新令牌)
|
|
type LogoutReq struct {
|
|
RefreshToken string `json:"refreshToken"`
|
|
}
|
|
|
|
// ChangePasswordReq 登录后修改密码
|
|
type ChangePasswordReq struct {
|
|
OldPassword string `json:"oldPassword" validate:"required"`
|
|
NewPassword string `json:"newPassword" validate:"required,password"`
|
|
}
|
|
|
|
// UserVO 用户信息(脱敏,不含密码)
|
|
type UserVO struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Phone string `json:"phone"`
|
|
Email string `json:"email"`
|
|
Role string `json:"role"`
|
|
TrafficBalance int64 `json:"trafficBalance"`
|
|
Status int8 `json:"status"`
|
|
LastLogin *time.Time `json:"lastLogin"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
}
|
|
|
|
// LoginResp 登录/刷新响应
|
|
type LoginResp struct {
|
|
AccessToken string `json:"accessToken"`
|
|
RefreshToken string `json:"refreshToken"`
|
|
User *UserVO `json:"user"`
|
|
}
|
|
|
|
// NewUserVO 由 model.User 构建脱敏 VO
|
|
func NewUserVO(u *model.User) *UserVO {
|
|
if u == nil {
|
|
return nil
|
|
}
|
|
return &UserVO{
|
|
ID: u.ID,
|
|
Name: u.Name,
|
|
Phone: u.Phone,
|
|
Email: u.Email,
|
|
Role: u.Role,
|
|
TrafficBalance: u.TrafficBalance,
|
|
Status: u.Status,
|
|
LastLogin: u.LastLogin,
|
|
CreatedAt: u.CreatedAt,
|
|
}
|
|
}
|
|
|