mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(provider): add status and banning mechanism
Introduce fields for managing provider status (active, auto_disabled, manual_disabled) and banning logic. - Add Status, AutoBan, BanReason, and BanUntil to Provider model and DTO - Update CreateProvider handler to process new fields with defaults - Extend sync service to propagate status and ban information in snapshots - Serialize BanUntil as Unix timestamp for sync compatibility
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -34,12 +36,16 @@ type Key struct {
|
||||
// Provider remains the same.
|
||||
type Provider struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Type string `gorm:"not null" json:"type"` // openai, anthropic, etc.
|
||||
BaseURL string `json:"base_url"`
|
||||
APIKey string `json:"api_key"`
|
||||
Group string `gorm:"default:'default'" json:"group"` // routing group/tier
|
||||
Models string `json:"models"` // comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo")
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Type string `gorm:"not null" json:"type"` // openai, anthropic, etc.
|
||||
BaseURL string `json:"base_url"`
|
||||
APIKey string `json:"api_key"`
|
||||
Group string `gorm:"default:'default'" json:"group"` // routing group/tier
|
||||
Models string `json:"models"` // comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo")
|
||||
Status string `gorm:"size:50;default:'active'" json:"status"` // active, auto_disabled, manual_disabled
|
||||
AutoBan bool `gorm:"default:true" json:"auto_ban"` // whether DP-triggered disable is allowed
|
||||
BanReason string `gorm:"size:255" json:"ban_reason"` // reason for current disable
|
||||
BanUntil *time.Time `json:"ban_until"` // optional TTL for disable
|
||||
}
|
||||
|
||||
// Model remains the same.
|
||||
|
||||
Reference in New Issue
Block a user