package app

import (
	"time"

	"git.echol.cn/loser/st/server/global"
	"gorm.io/datatypes"
)

// AppUserSession 前台用户会话
type AppUserSession struct {
	global.GVA_MODEL
	UserID           uint           `json:"userId" gorm:"index;comment:用户ID"`
	SessionToken     string         `json:"sessionToken" gorm:"type:varchar(500);uniqueIndex;comment:会话Token"`
	RefreshToken     string         `json:"refreshToken" gorm:"type:varchar(500);comment:刷新Token"`
	ExpiresAt        time.Time      `json:"expiresAt" gorm:"index;comment:过期时间"`
	RefreshExpiresAt *time.Time     `json:"refreshExpiresAt" gorm:"comment:刷新Token过期时间"`
	IPAddress        string         `json:"ipAddress" gorm:"type:varchar(100);comment:IP地址"`
	UserAgent        string         `json:"userAgent" gorm:"type:text;comment:用户代理"`
	DeviceInfo       datatypes.JSON `json:"deviceInfo" gorm:"type:jsonb;comment:设备信息"`
}

func (AppUserSession) TableName() string {
	return "app_user_sessions"
}
