feat(models): 模型目录与计费 - 按展示名分组并隔离管理员积分成本

This commit is contained in:
ddCat
2026-09-19 09:54:27 +08:00
parent 5ad05efb58
commit 237f2e2a6e
49 changed files with 802 additions and 276 deletions

View File

@@ -88,7 +88,6 @@ type AdminReferenceData struct {
type ChannelRequest struct {
Name string `json:"name"`
PublicAlias *string `json:"publicAlias"`
SortOrder *int `json:"sortOrder"`
BaseURL string `json:"baseUrl"`
APIKey string `json:"apiKey"`
@@ -106,7 +105,6 @@ type PublicModelChannel struct {
Scope model.ChannelScope `json:"scope"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
PublicAlias string `json:"publicAlias,omitempty"`
SortOrder int `json:"sortOrder"`
BaseURL string `json:"baseUrl"`
APIKey string `json:"apiKey"`
@@ -880,13 +878,6 @@ func (s *Service) channelFromRequest(req ChannelRequest, channel model.ModelChan
return channel, err
}
channel.Name = name
if req.PublicAlias != nil {
alias := strings.TrimSpace(*req.PublicAlias)
if len([]rune(alias)) > 80 {
return channel, BadAuthRequest("前台显示别名不能超过 80 个字符")
}
channel.PublicAlias = alias
}
if req.SortOrder != nil {
if err := validateChannelSortOrder(*req.SortOrder); err != nil {
return channel, err
@@ -971,17 +962,12 @@ func publicChannel(channel model.ModelChannel, admin bool, channelModels []model
} else if admin {
apiKey = channel.APIKey
}
name, alias := channel.PublicName(), ""
if admin {
name, alias = channel.Name, channel.PublicAlias
}
return PublicModelChannel{
ID: channel.ID,
UserID: channel.UserID,
Scope: channel.Scope,
Enabled: channel.Enabled,
Name: name,
PublicAlias: alias,
Name: channel.Name,
SortOrder: channel.SortOrder,
BaseURL: baseURL,
APIKey: apiKey,