fix: validate empty intervals + antigravity platform pricing match
- Backend: reject intervals with all-null price fields on save - Backend: filterValidIntervals skips empty intervals in pricing resolver - Frontend: red border + asterisk on empty interval rows - Backend: antigravity groups now match anthropic/gemini channel pricing
This commit is contained in:
@@ -2,6 +2,7 @@ package admin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -233,10 +234,26 @@ func validatePricingBillingMode(pricing []service.ChannelModelPricing) error {
|
||||
return errors.New("per-request price or intervals required for per_request/image billing mode")
|
||||
}
|
||||
}
|
||||
// 校验 interval:至少有一个价格字段非空
|
||||
for _, iv := range p.Intervals {
|
||||
if iv.InputPrice == nil && iv.OutputPrice == nil &&
|
||||
iv.CacheWritePrice == nil && iv.CacheReadPrice == nil &&
|
||||
iv.PerRequestPrice == nil {
|
||||
return fmt.Errorf("interval [%d, %s] has no price fields set for model %v",
|
||||
iv.MinTokens, formatMaxTokens(iv.MaxTokens), p.Models)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatMaxTokens(max *int) string {
|
||||
if max == nil {
|
||||
return "∞"
|
||||
}
|
||||
return fmt.Sprintf("%d", *max)
|
||||
}
|
||||
|
||||
// --- Handlers ---
|
||||
|
||||
// List handles listing channels with pagination
|
||||
|
||||
Reference in New Issue
Block a user