refactor(channels): normalize at cache fill and eliminate frontend as-cast

- channel.go: convert normalizeBillingModelSource into a (*Channel) method for entity cohesion
- channel_service.go: normalize in populateChannelCache so every cache-backed reader (gateway, billing, future endpoints) sees the default; drop the duplicate fallback inside resolveMapping
- table: tighten Row with status?: ChannelStatus / billing_model_source?: BillingModelSource, remove the [key: string]: unknown index signature
- admin view: drop the `as ChannelStatus` / `as BillingModelSource` assertions and add statusStyleOf / billingSourceLabelOf helpers with runtime fallback so unseen values render as "-" instead of crashing
This commit is contained in:
erio
2026-04-21 14:10:53 +08:00
parent 375aefa209
commit 4a3652ec09
5 changed files with 46 additions and 22 deletions

View File

@@ -66,7 +66,7 @@ func (s *ChannelService) ListAvailable(ctx context.Context) ([]AvailableChannel,
}
sort.SliceStable(groups, func(i, j int) bool { return groups[i].Name < groups[j].Name })
normalizeBillingModelSource(ch)
ch.normalizeBillingModelSource()
out = append(out, AvailableChannel{
ID: ch.ID,