mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(provider): add status and banning mechanism
Introduce fields for managing provider status (active, auto_disabled, manual_disabled) and banning logic. - Add Status, AutoBan, BanReason, and BanUntil to Provider model and DTO - Update CreateProvider handler to process new fields with defaults - Extend sync service to propagate status and ban information in snapshots - Serialize BanUntil as Unix timestamp for sync compatibility
This commit is contained in:
@@ -48,13 +48,29 @@ func (h *Handler) CreateProvider(c *gin.Context) {
|
||||
group = "default"
|
||||
}
|
||||
|
||||
status := strings.TrimSpace(req.Status)
|
||||
if status == "" {
|
||||
status = "active"
|
||||
}
|
||||
autoBan := true
|
||||
if req.AutoBan != nil {
|
||||
autoBan = *req.AutoBan
|
||||
}
|
||||
|
||||
provider := model.Provider{
|
||||
Name: req.Name,
|
||||
Type: req.Type,
|
||||
BaseURL: req.BaseURL,
|
||||
APIKey: req.APIKey,
|
||||
Group: group,
|
||||
Models: strings.Join(req.Models, ","),
|
||||
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,
|
||||
}
|
||||
if !req.BanUntil.IsZero() {
|
||||
tu := req.BanUntil.UTC()
|
||||
provider.BanUntil = &tu
|
||||
}
|
||||
|
||||
if err := h.db.Create(&provider).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user