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

@@ -9,6 +9,7 @@ import (
"github.com/ez-api/ez-api/internal/model"
groupx "github.com/ez-api/foundation/group"
"github.com/ez-api/foundation/jsoncodec"
"github.com/ez-api/foundation/routing"
"github.com/ez-api/foundation/tokenhash"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
@@ -407,9 +408,11 @@ func (s *SyncService) writeBindingsSnapshot(ctx context.Context, pipe redis.Pipe
}
key := ns + "." + pm
if err := s.hsetJSON(ctx, "config:bindings", key, snap); err != nil {
return err
payload, err := jsoncodec.Marshal(snap)
if err != nil {
return fmt.Errorf("marshal config:bindings:%s: %w", key, err)
}
pipe.HSet(ctx, "config:bindings", key, payload)
}
meta := map[string]string{