Files
st-react/server/model/app/response/auth.go
Echo f4e166c5ee 🎉 初始化项目
Signed-off-by: Echo <1711788888@qq.com>
2026-02-27 21:52:00 +08:00

56 lines
1.6 KiB
Go

package response
import (
"time"
"git.echol.cn/loser/st/server/model/app"
)
// AppUserResponse 用户信息响应
type AppUserResponse struct {
ID uint `json:"id"`
UUID string `json:"uuid"`
Username string `json:"username"`
NickName string `json:"nickName"`
Email string `json:"email"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
Status string `json:"status"`
Enable bool `json:"enable"`
IsAdmin bool `json:"isAdmin"`
LastLoginAt *time.Time `json:"lastLoginAt"`
LastLoginIP string `json:"lastLoginIp"`
ChatCount int `json:"chatCount"`
MessageCount int `json:"messageCount"`
CreatedAt time.Time `json:"createdAt"`
}
// LoginResponse 登录响应
type LoginResponse struct {
User AppUserResponse `json:"user"`
Token string `json:"token"`
RefreshToken string `json:"refreshToken"`
ExpiresAt int64 `json:"expiresAt"`
}
// ToAppUserResponse 转换为用户响应结构
func ToAppUserResponse(user *app.AppUser) AppUserResponse {
return AppUserResponse{
ID: user.ID,
UUID: user.UUID,
Username: user.Username,
NickName: user.NickName,
Email: user.Email,
Phone: user.Phone,
Avatar: user.Avatar,
Status: user.Status,
Enable: user.Enable,
IsAdmin: user.IsAdmin,
LastLoginAt: user.LastLoginAt,
LastLoginIP: user.LastLoginIP,
ChatCount: user.ChatCount,
MessageCount: user.MessageCount,
CreatedAt: user.CreatedAt,
}
}