49 lines
1.9 KiB
Go
49 lines
1.9 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// Client 表示 OAuth2 客户端
|
|
type Client struct {
|
|
ID uint `json:"id"`
|
|
ClientID string `json:"client_id" gorm:"unique"`
|
|
ClientSecret string `json:"client_secret,omitempty"`
|
|
Name string `json:"name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
RedirectURIs datatypes.JSON `gorm:"type:json"`
|
|
TokenEndpointAuthMethod string `gorm:"not null"`
|
|
GrantTypes datatypes.JSON `gorm:"type:json"`
|
|
ResponseTypes datatypes.JSON `gorm:"type:json"`
|
|
ClientName string `gorm:"type:varchar(255)"`
|
|
ClientURI string `gorm:"type:varchar(255)"`
|
|
LogoURI string `gorm:"type:varchar(255)"`
|
|
Scopes datatypes.JSON `gorm:"type:json"`
|
|
Contacts datatypes.JSON `gorm:"type:json"`
|
|
TosURI string `gorm:"type:varchar(255)"`
|
|
PolicyURI string `gorm:"type:varchar(255)"`
|
|
SoftwareID string `gorm:"type:varchar(255)"`
|
|
SoftwareVersion string `gorm:"type:varchar(255)"`
|
|
IsActive bool `gorm:"default:true"`
|
|
}
|
|
|
|
// CreateClientRequest 创建客户端的请求结构
|
|
type CreateClientRequest struct {
|
|
ClientID string `json:"client_id" binding:"required"`
|
|
ClientSecret string `json:"client_secret" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
}
|
|
|
|
// UpdateClientRequest 更新客户端的请求结构
|
|
type UpdateClientRequest struct {
|
|
ClientID string `json:"client_id" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
}
|
|
|
|
func (c *Client) TableName() string {
|
|
return "oauth_clients"
|
|
}
|