2025-12-26 15:40:24 +08:00
|
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
|
|
// Status constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
StatusActive = "active"
|
|
|
|
|
|
StatusDisabled = "disabled"
|
|
|
|
|
|
StatusError = "error"
|
|
|
|
|
|
StatusUnused = "unused"
|
|
|
|
|
|
StatusUsed = "used"
|
|
|
|
|
|
StatusExpired = "expired"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Role constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
RoleAdmin = "admin"
|
|
|
|
|
|
RoleUser = "user"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Platform constants
|
|
|
|
|
|
const (
|
2025-12-28 15:54:42 +08:00
|
|
|
|
PlatformAnthropic = "anthropic"
|
|
|
|
|
|
PlatformOpenAI = "openai"
|
|
|
|
|
|
PlatformGemini = "gemini"
|
|
|
|
|
|
PlatformAntigravity = "antigravity"
|
2025-12-26 15:40:24 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Account type constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
AccountTypeOAuth = "oauth" // OAuth类型账号(full scope: profile + inference)
|
|
|
|
|
|
AccountTypeSetupToken = "setup-token" // Setup Token类型账号(inference only scope)
|
2026-01-04 19:27:53 +08:00
|
|
|
|
AccountTypeAPIKey = "apikey" // API Key类型账号
|
2025-12-26 15:40:24 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Redeem type constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
RedeemTypeBalance = "balance"
|
|
|
|
|
|
RedeemTypeConcurrency = "concurrency"
|
|
|
|
|
|
RedeemTypeSubscription = "subscription"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-01-10 13:14:35 +08:00
|
|
|
|
// PromoCode status constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
PromoCodeStatusActive = "active"
|
|
|
|
|
|
PromoCodeStatusDisabled = "disabled"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-26 15:40:24 +08:00
|
|
|
|
// Admin adjustment type constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
AdjustmentTypeAdminBalance = "admin_balance" // 管理员调整余额
|
|
|
|
|
|
AdjustmentTypeAdminConcurrency = "admin_concurrency" // 管理员调整并发数
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Group subscription type constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
SubscriptionTypeStandard = "standard" // 标准计费模式(按余额扣费)
|
|
|
|
|
|
SubscriptionTypeSubscription = "subscription" // 订阅模式(按限额控制)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Subscription status constants
|
|
|
|
|
|
const (
|
|
|
|
|
|
SubscriptionStatusActive = "active"
|
|
|
|
|
|
SubscriptionStatusExpired = "expired"
|
|
|
|
|
|
SubscriptionStatusSuspended = "suspended"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-01-11 11:11:37 +08:00
|
|
|
|
// LinuxDoConnectSyntheticEmailDomain 是 LinuxDo Connect 用户的合成邮箱后缀(RFC 保留域名)。
|
|
|
|
|
|
const LinuxDoConnectSyntheticEmailDomain = "@linuxdo-connect.invalid"
|
|
|
|
|
|
|
2025-12-26 15:40:24 +08:00
|
|
|
|
// Setting keys
|
|
|
|
|
|
const (
|
|
|
|
|
|
// 注册设置
|
|
|
|
|
|
SettingKeyRegistrationEnabled = "registration_enabled" // 是否开放注册
|
|
|
|
|
|
SettingKeyEmailVerifyEnabled = "email_verify_enabled" // 是否开启邮件验证
|
|
|
|
|
|
|
|
|
|
|
|
// 邮件服务设置
|
2026-01-04 19:27:53 +08:00
|
|
|
|
SettingKeySMTPHost = "smtp_host" // SMTP服务器地址
|
|
|
|
|
|
SettingKeySMTPPort = "smtp_port" // SMTP端口
|
|
|
|
|
|
SettingKeySMTPUsername = "smtp_username" // SMTP用户名
|
|
|
|
|
|
SettingKeySMTPPassword = "smtp_password" // SMTP密码(加密存储)
|
|
|
|
|
|
SettingKeySMTPFrom = "smtp_from" // 发件人地址
|
|
|
|
|
|
SettingKeySMTPFromName = "smtp_from_name" // 发件人名称
|
|
|
|
|
|
SettingKeySMTPUseTLS = "smtp_use_tls" // 是否使用TLS
|
2025-12-26 15:40:24 +08:00
|
|
|
|
|
|
|
|
|
|
// Cloudflare Turnstile 设置
|
|
|
|
|
|
SettingKeyTurnstileEnabled = "turnstile_enabled" // 是否启用 Turnstile 验证
|
|
|
|
|
|
SettingKeyTurnstileSiteKey = "turnstile_site_key" // Turnstile Site Key
|
|
|
|
|
|
SettingKeyTurnstileSecretKey = "turnstile_secret_key" // Turnstile Secret Key
|
|
|
|
|
|
|
2026-01-11 10:59:01 +08:00
|
|
|
|
// LinuxDo Connect OAuth 登录设置
|
|
|
|
|
|
SettingKeyLinuxDoConnectEnabled = "linuxdo_connect_enabled"
|
|
|
|
|
|
SettingKeyLinuxDoConnectClientID = "linuxdo_connect_client_id"
|
|
|
|
|
|
SettingKeyLinuxDoConnectClientSecret = "linuxdo_connect_client_secret"
|
|
|
|
|
|
SettingKeyLinuxDoConnectRedirectURL = "linuxdo_connect_redirect_url"
|
|
|
|
|
|
|
2025-12-26 15:40:24 +08:00
|
|
|
|
// OEM设置
|
|
|
|
|
|
SettingKeySiteName = "site_name" // 网站名称
|
|
|
|
|
|
SettingKeySiteLogo = "site_logo" // 网站Logo (base64)
|
|
|
|
|
|
SettingKeySiteSubtitle = "site_subtitle" // 网站副标题
|
2026-01-04 19:27:53 +08:00
|
|
|
|
SettingKeyAPIBaseURL = "api_base_url" // API端点地址(用于客户端配置和导入)
|
2025-12-26 15:40:24 +08:00
|
|
|
|
SettingKeyContactInfo = "contact_info" // 客服联系方式
|
2026-01-04 19:27:53 +08:00
|
|
|
|
SettingKeyDocURL = "doc_url" // 文档链接
|
2026-01-10 18:37:44 +08:00
|
|
|
|
SettingKeyHomeContent = "home_content" // 首页内容(支持 Markdown/HTML,或 URL 作为 iframe src)
|
2025-12-26 15:40:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 默认配置
|
|
|
|
|
|
SettingKeyDefaultConcurrency = "default_concurrency" // 新用户默认并发量
|
|
|
|
|
|
SettingKeyDefaultBalance = "default_balance" // 新用户默认余额
|
|
|
|
|
|
|
|
|
|
|
|
// 管理员 API Key
|
2026-01-04 19:27:53 +08:00
|
|
|
|
SettingKeyAdminAPIKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成)
|
2026-01-01 04:22:39 +08:00
|
|
|
|
|
|
|
|
|
|
// Gemini 配额策略(JSON)
|
|
|
|
|
|
SettingKeyGeminiQuotaPolicy = "gemini_quota_policy"
|
2026-01-03 06:37:08 -08:00
|
|
|
|
|
|
|
|
|
|
// Model fallback settings
|
|
|
|
|
|
SettingKeyEnableModelFallback = "enable_model_fallback"
|
|
|
|
|
|
SettingKeyFallbackModelAnthropic = "fallback_model_anthropic"
|
|
|
|
|
|
SettingKeyFallbackModelOpenAI = "fallback_model_openai"
|
|
|
|
|
|
SettingKeyFallbackModelGemini = "fallback_model_gemini"
|
|
|
|
|
|
SettingKeyFallbackModelAntigravity = "fallback_model_antigravity"
|
2026-01-04 22:49:40 +08:00
|
|
|
|
|
|
|
|
|
|
// Request identity patch (Claude -> Gemini systemInstruction injection)
|
|
|
|
|
|
SettingKeyEnableIdentityPatch = "enable_identity_patch"
|
|
|
|
|
|
SettingKeyIdentityPatchPrompt = "identity_patch_prompt"
|
2026-01-09 20:53:44 +08:00
|
|
|
|
|
|
|
|
|
|
// =========================
|
|
|
|
|
|
// Ops Monitoring (vNext)
|
|
|
|
|
|
// =========================
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsMonitoringEnabled is a DB-backed soft switch to enable/disable ops module at runtime.
|
|
|
|
|
|
SettingKeyOpsMonitoringEnabled = "ops_monitoring_enabled"
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsRealtimeMonitoringEnabled controls realtime features (e.g. WS/QPS push).
|
|
|
|
|
|
SettingKeyOpsRealtimeMonitoringEnabled = "ops_realtime_monitoring_enabled"
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsQueryModeDefault controls the default query mode for ops dashboard (auto/raw/preagg).
|
|
|
|
|
|
SettingKeyOpsQueryModeDefault = "ops_query_mode_default"
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsEmailNotificationConfig stores JSON config for ops email notifications.
|
|
|
|
|
|
SettingKeyOpsEmailNotificationConfig = "ops_email_notification_config"
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsAlertRuntimeSettings stores JSON config for ops alert evaluator runtime settings.
|
|
|
|
|
|
SettingKeyOpsAlertRuntimeSettings = "ops_alert_runtime_settings"
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsMetricsIntervalSeconds controls the ops metrics collector interval (>=60).
|
|
|
|
|
|
SettingKeyOpsMetricsIntervalSeconds = "ops_metrics_interval_seconds"
|
2026-01-11 19:51:18 +08:00
|
|
|
|
|
|
|
|
|
|
// SettingKeyOpsAdvancedSettings stores JSON config for ops advanced settings (data retention, aggregation).
|
|
|
|
|
|
SettingKeyOpsAdvancedSettings = "ops_advanced_settings"
|
2026-01-11 21:54:52 -08:00
|
|
|
|
|
|
|
|
|
|
// =========================
|
|
|
|
|
|
// Stream Timeout Handling
|
|
|
|
|
|
// =========================
|
|
|
|
|
|
|
|
|
|
|
|
// SettingKeyStreamTimeoutSettings stores JSON config for stream timeout handling.
|
|
|
|
|
|
SettingKeyStreamTimeoutSettings = "stream_timeout_settings"
|
2025-12-26 15:40:24 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2026-01-04 19:27:53 +08:00
|
|
|
|
// AdminAPIKeyPrefix is the prefix for admin API keys (distinct from user "sk-" keys).
|
|
|
|
|
|
const AdminAPIKeyPrefix = "admin-"
|