mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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:
@@ -62,6 +62,8 @@ func (h *Handler) CreateProvider(c *gin.Context) {
|
|||||||
Type: req.Type,
|
Type: req.Type,
|
||||||
BaseURL: req.BaseURL,
|
BaseURL: req.BaseURL,
|
||||||
APIKey: req.APIKey,
|
APIKey: req.APIKey,
|
||||||
|
GoogleProject: strings.TrimSpace(req.GoogleProject),
|
||||||
|
GoogleLocation: strings.TrimSpace(req.GoogleLocation),
|
||||||
Group: group,
|
Group: group,
|
||||||
Models: strings.Join(req.Models, ","),
|
Models: strings.Join(req.Models, ","),
|
||||||
Status: status,
|
Status: status,
|
||||||
@@ -133,6 +135,12 @@ func (h *Handler) UpdateProvider(c *gin.Context) {
|
|||||||
if req.APIKey != "" {
|
if req.APIKey != "" {
|
||||||
update["api_key"] = req.APIKey
|
update["api_key"] = req.APIKey
|
||||||
}
|
}
|
||||||
|
if strings.TrimSpace(req.GoogleProject) != "" {
|
||||||
|
update["google_project"] = strings.TrimSpace(req.GoogleProject)
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(req.GoogleLocation) != "" {
|
||||||
|
update["google_location"] = strings.TrimSpace(req.GoogleLocation)
|
||||||
|
}
|
||||||
if req.Models != nil {
|
if req.Models != nil {
|
||||||
update["models"] = strings.Join(req.Models, ",")
|
update["models"] = strings.Join(req.Models, ",")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ type ProviderDTO struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
BaseURL string `json:"base_url"`
|
BaseURL string `json:"base_url"`
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
|
GoogleProject string `json:"google_project,omitempty"`
|
||||||
|
GoogleLocation string `json:"google_location,omitempty"`
|
||||||
Group string `json:"group"`
|
Group string `json:"group"`
|
||||||
Models []string `json:"models"` // List of supported model names
|
Models []string `json:"models"` // List of supported model names
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ type Provider struct {
|
|||||||
Type string `gorm:"not null" json:"type"` // openai, anthropic, etc.
|
Type string `gorm:"not null" json:"type"` // openai, anthropic, etc.
|
||||||
BaseURL string `json:"base_url"`
|
BaseURL string `json:"base_url"`
|
||||||
APIKey string `json:"api_key"`
|
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
|
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")
|
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
|
Status string `gorm:"size:50;default:'active'" json:"status"` // active, auto_disabled, manual_disabled
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ func (s *SyncService) SyncProvider(provider *model.Provider) error {
|
|||||||
Type: provider.Type,
|
Type: provider.Type,
|
||||||
BaseURL: provider.BaseURL,
|
BaseURL: provider.BaseURL,
|
||||||
APIKey: provider.APIKey,
|
APIKey: provider.APIKey,
|
||||||
|
GoogleProject: provider.GoogleProject,
|
||||||
|
GoogleLocation: provider.GoogleLocation,
|
||||||
Group: group,
|
Group: group,
|
||||||
Models: models,
|
Models: models,
|
||||||
Status: normalizeStatus(provider.Status),
|
Status: normalizeStatus(provider.Status),
|
||||||
@@ -129,6 +131,8 @@ type providerSnapshot struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
BaseURL string `json:"base_url"`
|
BaseURL string `json:"base_url"`
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
|
GoogleProject string `json:"google_project,omitempty"`
|
||||||
|
GoogleLocation string `json:"google_location,omitempty"`
|
||||||
Group string `json:"group"`
|
Group string `json:"group"`
|
||||||
Models []string `json:"models"`
|
Models []string `json:"models"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
@@ -203,6 +207,8 @@ func (s *SyncService) SyncAll(db *gorm.DB) error {
|
|||||||
Type: p.Type,
|
Type: p.Type,
|
||||||
BaseURL: p.BaseURL,
|
BaseURL: p.BaseURL,
|
||||||
APIKey: p.APIKey,
|
APIKey: p.APIKey,
|
||||||
|
GoogleProject: p.GoogleProject,
|
||||||
|
GoogleLocation: p.GoogleLocation,
|
||||||
Group: group,
|
Group: group,
|
||||||
Models: models,
|
Models: models,
|
||||||
Status: normalizeStatus(p.Status),
|
Status: normalizeStatus(p.Status),
|
||||||
|
|||||||
Reference in New Issue
Block a user