55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package response
|
|
|
|
import (
|
|
"git.echol.cn/loser/st/server/model/app"
|
|
"time"
|
|
)
|
|
|
|
// LoginResponse 登录响应
|
|
type LoginResponse struct {
|
|
User AppUserResponse `json:"user"`
|
|
Token string `json:"token"`
|
|
RefreshToken string `json:"refreshToken"`
|
|
ExpiresAt int64 `json:"expiresAt"` // Unix 时间戳
|
|
}
|
|
|
|
// 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"`
|
|
LastLoginAt *time.Time `json:"lastLoginAt"`
|
|
ChatCount int `json:"chatCount"`
|
|
MessageCount int `json:"messageCount"`
|
|
AISettings interface{} `json:"aiSettings"`
|
|
Preferences interface{} `json:"preferences"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
}
|
|
|
|
// ToAppUserResponse 将 AppUser 转换为 AppUserResponse
|
|
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,
|
|
LastLoginAt: user.LastLoginAt,
|
|
ChatCount: user.ChatCount,
|
|
MessageCount: user.MessageCount,
|
|
AISettings: user.AISettings,
|
|
Preferences: user.Preferences,
|
|
CreatedAt: user.CreatedAt,
|
|
}
|
|
}
|