refactor: replace magic strings with named constants

- PricingSourceChannel/LiteLLM/Fallback for resolver source
- MediaTypeImage/Video/Prompt for result.MediaType
- Reuse BillingModeToken/BillingModeImage for billing mode
- Reuse BillingModelSourceChannelMapped/PlatformAnthropic in handler
This commit is contained in:
erio
2026-04-02 02:22:15 +08:00
parent 212eaa3a05
commit 0d241d52eb
4 changed files with 39 additions and 19 deletions

View File

@@ -130,7 +130,7 @@ func channelToResponse(ch *service.Channel) *channelResponse {
}
resp.BillingModelSource = ch.BillingModelSource
if resp.BillingModelSource == "" {
resp.BillingModelSource = "channel_mapped"
resp.BillingModelSource = service.BillingModelSourceChannelMapped
}
if resp.GroupIDs == nil {
resp.GroupIDs = []int64{}
@@ -147,11 +147,11 @@ func channelToResponse(ch *service.Channel) *channelResponse {
}
billingMode := string(p.BillingMode)
if billingMode == "" {
billingMode = "token"
billingMode = string(service.BillingModeToken)
}
platform := p.Platform
if platform == "" {
platform = "anthropic"
platform = service.PlatformAnthropic
}
intervals := make([]pricingIntervalResponse, 0, len(p.Intervals))
for _, iv := range p.Intervals {
@@ -194,7 +194,7 @@ func pricingRequestToService(reqs []channelModelPricingRequest) []service.Channe
}
platform := r.Platform
if platform == "" {
platform = "anthropic"
platform = service.PlatformAnthropic
}
intervals := make([]service.PricingInterval, 0, len(r.Intervals))
for _, iv := range r.Intervals {