mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(provider): add update endpoint and enforce status checks
Add `PUT /admin/providers/{id}` endpoint to allow updating provider
configurations, including status and ban details. Update synchronization
logic to exclude inactive or banned providers from routing tables to
ensure traffic is not routed to them.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/ez-api/ez-api/internal/model"
|
||||
@@ -93,6 +94,12 @@ func (s *SyncService) SyncProvider(provider *model.Provider) error {
|
||||
if m == "" {
|
||||
continue
|
||||
}
|
||||
if snap.Status != "active" {
|
||||
continue
|
||||
}
|
||||
if snap.BanUntil > 0 && time.Now().Unix() < snap.BanUntil {
|
||||
continue
|
||||
}
|
||||
routeKey := fmt.Sprintf("route:group:%s:%s", group, m)
|
||||
pipe.SAdd(ctx, routeKey, provider.ID)
|
||||
}
|
||||
@@ -217,6 +224,12 @@ func (s *SyncService) SyncAll(db *gorm.DB) error {
|
||||
if m == "" {
|
||||
continue
|
||||
}
|
||||
if snap.Status != "active" {
|
||||
continue
|
||||
}
|
||||
if snap.BanUntil > 0 && time.Now().Unix() < snap.BanUntil {
|
||||
continue
|
||||
}
|
||||
routeKey := fmt.Sprintf("route:group:%s:%s", group, m)
|
||||
pipe.SAdd(ctx, routeKey, p.ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user