更新依赖项,添加单元测试,优化用户信息和令牌管理功能,增强中间件以支持 JWT 验证,新增访问令牌模型并更新数据库迁移。

This commit is contained in:
2025-04-17 02:04:52 +08:00
parent 83c82f7135
commit d06e45e5d4
10 changed files with 482 additions and 14 deletions

22
models/access_token.go Normal file
View File

@@ -0,0 +1,22 @@
package models
import (
"time"
"gorm.io/gorm"
)
// AccessToken 表示 OAuth2 访问令牌
type AccessToken struct {
gorm.Model
Token string `gorm:"uniqueIndex;not null"`
UserID uint `gorm:"not null"`
ClientID string `gorm:"not null"`
Scope string `gorm:"type:text"`
ExpiresAt time.Time `gorm:"not null"`
IsRevoked bool `gorm:"default:false"`
}
func (t *AccessToken) TableName() string {
return "oauth_access_tokens"
}