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

@@ -58,15 +58,17 @@ func (h *Handler) CreateProvider(c *gin.Context) {
}
provider := model.Provider{
Name: req.Name,
Type: req.Type,
BaseURL: req.BaseURL,
APIKey: req.APIKey,
Group: group,
Models: strings.Join(req.Models, ","),
Status: status,
AutoBan: autoBan,
BanReason: req.BanReason,
Name: req.Name,
Type: req.Type,
BaseURL: req.BaseURL,
APIKey: req.APIKey,
GoogleProject: strings.TrimSpace(req.GoogleProject),
GoogleLocation: strings.TrimSpace(req.GoogleLocation),
Group: group,
Models: strings.Join(req.Models, ","),
Status: status,
AutoBan: autoBan,
BanReason: req.BanReason,
}
if !req.BanUntil.IsZero() {
tu := req.BanUntil.UTC()
@@ -133,6 +135,12 @@ func (h *Handler) UpdateProvider(c *gin.Context) {
if 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 {
update["models"] = strings.Join(req.Models, ",")
}