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,
	}
}
