From 435bc487cf985c8a72f93bea288a0237d0356313 Mon Sep 17 00:00:00 2001 From: ddcat666 <26564566+ddcat666@users.noreply.github.com> Date: Sun, 11 Oct 2026 22:22:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E6=A8=A1=E5=9E=8B=E8=AE=A1?= =?UTF-8?q?=E4=BB=B7=20-=20=E5=85=BC=E5=AE=B9=E5=9B=BE=E7=89=87=E5=88=86?= =?UTF-8?q?=E8=BE=A8=E7=8E=87=E5=AD=97=E6=AE=B5=E6=8B=BC=E5=86=99=E5=B9=B6?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/app/channel_model_pricing_test.go | 12 +++++++++++- backend/internal/app/channel_models_pricing.go | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/internal/app/channel_model_pricing_test.go b/backend/internal/app/channel_model_pricing_test.go index 68fed0790..aa5e61ee2 100644 --- a/backend/internal/app/channel_model_pricing_test.go +++ b/backend/internal/app/channel_model_pricing_test.go @@ -219,7 +219,17 @@ func TestRepriceTierFieldValidation(t *testing.T) { } } -func TestBatchRepricingRollsBackOnConcurrentChange(t *testing.T) { +func TestNormalizeChannelModelTierSelectorAcceptsResolutionTypo(t *testing.T) { + selector, resolution, videoSeconds, err := normalizeChannelModelTierSelector("image", ChannelModelPriceTierRequest{ + Selector: map[string]string{"resoluton": "2K"}, + }) + if err != nil { + t.Fatal(err) + } + if selector["resolution"] != "2k" || selector["resoluton"] != "" || resolution != "*" || videoSeconds != 0 { + t.Fatalf("selector=%v resolution=%q videoSeconds=%d", selector, resolution, videoSeconds) + } +} for _, target := range []string{"model", "tier"} { t.Run(target, func(t *testing.T) { svc, db, _ := seedRepricingModels(t) diff --git a/backend/internal/app/channel_models_pricing.go b/backend/internal/app/channel_models_pricing.go index 07a86ce8f..773ce4d68 100644 --- a/backend/internal/app/channel_models_pricing.go +++ b/backend/internal/app/channel_models_pricing.go @@ -144,6 +144,10 @@ func normalizeChannelModelTierSelector(capability string, input ChannelModelPric } case "vquality": value = normalizeChannelModelTierResolution(value) + case "resolution", "resoluton": + // 兼容图片价格档的标准字段,以及历史接口误拼写 resoluton。 + key = "resolution" + value = strings.ToLower(strings.TrimSpace(value)) case "videoSeconds": seconds, err := strconv.Atoi(value) if err != nil || seconds < 0 { @@ -200,6 +204,9 @@ func normalizeChannelModelTierSelector(capability string, input ChannelModelPric if _, exists := selector["vquality"]; exists && capability != "video" { return nil, "", 0, BadAuthRequest("只有视频模型可以按分辨率配置价格档") } + if _, exists := selector["resolution"]; exists && capability != "image" { + return nil, "", 0, BadAuthRequest("只有图片模型可以按分辨率配置价格档") + } if _, exists := selector["videoSeconds"]; exists && capability != "video" { return nil, "", 0, BadAuthRequest("只有视频模型可以按时长配置价格档") }