package model

import "time"

type OAuthAccount struct {
	ID           int64     `json:"id" gorm:"primaryKey;autoIncrement"`
	UserID       int64     `json:"user_id" gorm:"not null;index"`
	Provider     string    `json:"provider" gorm:"size:20;not null;uniqueIndex:idx_oauth_provider_openid"`
	OpenID       string    `json:"openid" gorm:"size:128;not null;uniqueIndex:idx_oauth_provider_openid"`
	UnionID      string    `json:"unionid" gorm:"size:128;not null;default:'';index"`
	Nickname     string    `json:"nickname" gorm:"size:100;not null;default:''"`
	Avatar       string    `json:"avatar" gorm:"size:500;not null;default:''"`
	AccessToken  string    `json:"-" gorm:"column:access_token;size:1024;not null;default:''"`
	RefreshToken string    `json:"-" gorm:"column:refresh_token;size:1024;not null;default:''"`
	ExpiresAt    time.Time `json:"expires_at" gorm:"type:timestamp(0)"`
	CreatedAt    time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"`
	UpdatedAt    time.Time `json:"updated_at" gorm:"not null;autoUpdateTime;type:timestamp(0)"`
}

func (OAuthAccount) TableName() string {
	return "auth_oauth_accounts"
}
