fix(channel): 模型限制用映射后模型检查 + 平台开关保留配置不删除

- OpenAI 网关三处 IsModelRestricted 改用 channelMapping.MappedModel
- 前端平台勾选改为 enabled 开关,取消勾选不清空配置数据
- formToAPI/校验只处理 enabled 的平台
This commit is contained in:
erio
2026-03-31 01:34:16 +08:00
parent 8d03c52e15
commit 91bdcf8994
3 changed files with 26 additions and 35 deletions

View File

@@ -164,9 +164,9 @@ func (h *GatewayHandler) Messages(c *gin.Context) {
channelMapping = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel)
}
// 渠道模型限制检查:使用原始请求模型名,因为定价列表中注册的是用户请求的模型名
// 渠道模型限制检查:先映射再判断,映射后的模型在定价列表中即放行
if apiKey.GroupID != nil {
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) {
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMapping.MappedModel) {
h.errorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts")
return
}