新增客户端管理功能,包括创建、编辑和删除客户端的API,更新用户管理功能,添加用户创建和编辑页面,优化管理员功能,增强用户和客户端的管理体验。

This commit is contained in:
2025-04-17 02:29:16 +08:00
parent d06e45e5d4
commit ff47bb2f6f
11 changed files with 823 additions and 77 deletions

View File

@@ -4,13 +4,16 @@ import (
"time"
"gorm.io/datatypes"
"gorm.io/gorm"
)
// Client 表示 OAuth2 客户端
type Client struct {
gorm.Model
ClientID string `gorm:"uniqueIndex;not null"`
ClientSecret string `gorm:"not null"`
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"`
@@ -25,8 +28,19 @@ type Client struct {
SoftwareID string `gorm:"type:varchar(255)"`
SoftwareVersion string `gorm:"type:varchar(255)"`
IsActive bool `gorm:"default:true"`
CreatedAt time.Time
UpdatedAt time.Time
}
// 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 {