package session

import "time"

// Session [...]
type Session struct {
	SessionID       int64     `gorm:"primaryKey;column:session_id;type:bigint(12);not null" json:"sessionId"`
	UserID          int64     `gorm:"index:session_user;column:user_id;type:bigint(20);not null" json:"userId"`
	OpenID          string    `gorm:"column:open_id;type:varchar(32);not null" json:"openId"` // openid
	AccessToken     string    `gorm:"index:session_token;column:access_token;type:varchar(64);not null" json:"accessToken"`
	ExpireTime      time.Time `gorm:"index:expire_time;column:expire_time;type:datetime;not null" json:"expireTime"`
	CreatedTime     time.Time `gorm:"column:created_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createdTime"` // 创建时间
	LastUpdatedTime time.Time `gorm:"column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"lastUpdatedTime"`
}

// TableName get sql table name.获取数据库表名
func (m *Session) TableName() string {
	return "session"
}

// SessionColumns get sql column name.获取数据库列名
var SessionColumns = struct {
	SessionID       string
	UserID          string
	OpenID          string
	AccessToken     string
	ExpireTime      string
	CreatedTime     string
	LastUpdatedTime string
}{
	SessionID:       "session_id",
	UserID:          "user_id",
	OpenID:          "open_id",
	AccessToken:     "access_token",
	ExpireTime:      "expire_time",
	CreatedTime:     "created_time",
	LastUpdatedTime: "last_updated_time",
}
