feat(provider): add google project and location fields

Add support for Google Cloud-specific configuration in provider models.
New fields `GoogleProject` and `GoogleLocation` are now included in the
Provider DTO, database model, API handlers, and sync service snapshots.

- Extend Provider struct in model with gorm/json tags
- Update ProviderDTO with omitempty JSON tags
- Include fields in handler create/update logic with trim
- Add fields to providerSnapshot for sync operations
This commit is contained in:
zenfun
2025-12-13 20:24:44 +08:00
parent 89cb74ba6e
commit 67df74e09a
4 changed files with 78 additions and 60 deletions

View File

@@ -36,16 +36,18 @@ 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")
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
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"`
GoogleProject string `gorm:"size:128" json:"google_project,omitempty"`
GoogleLocation string `gorm:"size:64" json:"google_location,omitempty"`
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.