b2cae2471d
- 新增AdminUser类型定义及用户管理API接口 - 实现用户列表查询、保存和删除功能 - 添加Linux.do第三方登录支持 - 集成Linux.do OAuth认证流程 - 在系统设置中添加Linux.do登录配置选项 - 实现算力点余额调整记录功能 - 优化搜索组件关键词状态管理 - 更新数据库迁移添加credit_logs表 - 完善用户状态和信用等级验证逻辑
86 lines
2.4 KiB
Go
86 lines
2.4 KiB
Go
package model
|
|
|
|
import "encoding/json"
|
|
|
|
type SettingKey string
|
|
|
|
const (
|
|
SettingKeyPublic SettingKey = "public"
|
|
SettingKeyPrivate SettingKey = "private"
|
|
)
|
|
|
|
// ModelChannel 模型渠道配置。
|
|
type ModelChannel struct {
|
|
Protocol string `json:"protocol"`
|
|
Name string `json:"name"`
|
|
BaseURL string `json:"baseUrl"`
|
|
APIKey string `json:"apiKey"`
|
|
Models []string `json:"models"`
|
|
Weight int `json:"weight"`
|
|
Enabled bool `json:"enabled"`
|
|
Remark string `json:"remark"`
|
|
}
|
|
|
|
// PublicModelChannelSetting 公开模型渠道配置。
|
|
type PublicModelChannelSetting struct {
|
|
AvailableModels []string `json:"availableModels"`
|
|
DefaultModel string `json:"defaultModel"`
|
|
DefaultImageModel string `json:"defaultImageModel"`
|
|
DefaultVideoModel string `json:"defaultVideoModel"`
|
|
DefaultTextModel string `json:"defaultTextModel"`
|
|
SystemPrompt string `json:"systemPrompt"`
|
|
AllowCustomChannel *bool `json:"allowCustomChannel"`
|
|
}
|
|
|
|
// PublicSetting 公开配置。
|
|
type PublicSetting struct {
|
|
ModelChannel PublicModelChannelSetting `json:"modelChannel"`
|
|
Auth PublicAuthSetting `json:"auth"`
|
|
}
|
|
|
|
type PublicAuthSetting struct {
|
|
LinuxDo PublicLinuxDoAuthSetting `json:"linuxDo"`
|
|
}
|
|
|
|
type PublicLinuxDoAuthSetting struct {
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
// PrivateSetting 私有配置。
|
|
type PrivateSetting struct {
|
|
Channels []ModelChannel `json:"channels"`
|
|
PromptSync PromptSyncSetting `json:"promptSync"`
|
|
Auth PrivateAuthSetting `json:"auth"`
|
|
}
|
|
|
|
// PromptSyncSetting 提示词定时同步配置。
|
|
type PromptSyncSetting struct {
|
|
Enabled *bool `json:"enabled"`
|
|
Cron string `json:"cron"`
|
|
}
|
|
|
|
type PrivateAuthSetting struct {
|
|
LinuxDo PrivateLinuxDoAuthSetting `json:"linuxDo"`
|
|
}
|
|
|
|
type PrivateLinuxDoAuthSetting struct {
|
|
ClientID string `json:"clientId"`
|
|
ClientSecret string `json:"clientSecret"`
|
|
RedirectURI string `json:"redirectUri"`
|
|
MinimumTrustLevel int `json:"minimumTrustLevel"`
|
|
}
|
|
|
|
// Setting 系统配置。
|
|
type Setting struct {
|
|
Key SettingKey `json:"key" gorm:"primaryKey"`
|
|
Value json.RawMessage `json:"value" gorm:"serializer:json"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
}
|
|
|
|
// Settings 系统公开和私有配置。
|
|
type Settings struct {
|
|
Public PublicSetting `json:"public"`
|
|
Private PrivateSetting `json:"private"`
|
|
}
|