feat(api): add admin endpoints for binding management

Implement handlers for creating, listing, and updating model bindings.
Register new routes in the admin server group and add DTO definitions.
Update provider handlers to trigger binding synchronization on changes
to ensure upstream mappings remain current.
This commit is contained in:
zenfun
2025-12-17 00:37:02 +08:00
parent 2e3b471533
commit ed6446e586
5 changed files with 190 additions and 2 deletions

View File

@@ -89,6 +89,11 @@ func (h *Handler) CreateProvider(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to sync provider", "details": err.Error()})
return
}
// Provider model list changes can affect binding upstream mappings; rebuild bindings snapshot.
if err := h.sync.SyncBindings(h.db); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to sync bindings", "details": err.Error()})
return
}
c.JSON(http.StatusCreated, provider)
}
@@ -196,6 +201,10 @@ func (h *Handler) UpdateProvider(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to sync provider", "details": err.Error()})
return
}
if err := h.sync.SyncBindings(h.db); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to sync bindings", "details": err.Error()})
return
}
c.JSON(http.StatusOK, existing)
}