userOAuth

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(entity *Entity) error

Create 创建OAuth记录

func Delete

func Delete(id uint64) error

Delete 删除OAuth记录

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func Update

func Update(entity *Entity) error

Update 更新OAuth记录

Types

type Entity

type Entity struct {
	Id       uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`                                                        // id
	UserId   uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;index;index:idx_user_provider,priority:1" json:"userId"` // 关联用户id
	Provider string ``                                                                                                                     // 平台标识(github/twitter)
	/* 134-byte string literal not displayed */
	ProviderUid  string    `gorm:"column:provider_uid;type:varchar(255);not null;default:'';index;index:idx_provider_uid,priority:2" json:"providerUid"` // 第三方用户唯一ID
	AccessToken  string    `gorm:"column:access_token;type:varchar(1024);not null;default:'';" json:"accessToken"`                                       // 访问令牌
	RefreshToken string    `gorm:"column:refresh_token;type:varchar(1024);not null;default:'';" json:"refreshToken"`                                     // 刷新令牌
	TokenExpiry  time.Time `gorm:"column:token_expiry;type:datetime;" json:"tokenExpiry"`                                                                // 令牌过期时间
	Scopes       string    `gorm:"column:scopes;type:text;" json:"scopes"`                                                                               // 授权范围
	RawUserData  string    `gorm:"column:raw_user_data;type:text;" json:"rawUserData"`                                                                   // 平台返回的原始用户数据
	CreatedAt    time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"`                                                   //
	UpdatedAt    time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
}

func Get

func Get(id any) (entity Entity)

func GetByProviderAndUID

func GetByProviderAndUID(provider, providerUID string) *Entity

GetByProviderAndUID 根据提供商和UID获取OAuth记录

func GetByUserIDAndProvider

func GetByUserIDAndProvider(userID uint64, provider string) *Entity

GetByUserIDAndProvider 根据用户ID和提供商获取OAuth记录

func (*Entity) TableName

func (itself *Entity) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL