From 5bb7dfb7cd04ca625389ee8a4bdbaf88cf11a04a Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 3 Jan 2026 14:39:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20token=20=E4=B8=8B=E6=8B=89=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=94=AF=E6=8C=81=E5=8F=AF=E9=80=89=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E9=BB=98=E8=AE=A4=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 GetSelectListAsync 接口新增 includeDefault 查询参数,允许调用方控制是否返回“默认”选项,默认保持原有行为。 --- .../Services/Chat/TokenService.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs index 2e192c62..204fda55 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs @@ -26,6 +26,7 @@ public class TokenService : ApplicationService private readonly ISqlSugarRepository _tokenRepository; private readonly ISqlSugarRepository _usageStatisticsRepository; private readonly ModelManager _modelManager; + public TokenService( ISqlSugarRepository tokenRepository, ISqlSugarRepository usageStatisticsRepository, @@ -90,7 +91,7 @@ public class TokenService : ApplicationService } [HttpGet("token/select-list")] - public async Task> GetSelectListAsync() + public async Task> GetSelectListAsync([FromQuery] bool? includeDefault = true) { var userId = CurrentUser.GetId(); var tokens = await _tokenRepository._DbQueryable @@ -103,13 +104,17 @@ public class TokenService : ApplicationService Name = x.Name, IsDisabled = x.IsDisabled }).ToListAsync(); - - tokens.Insert(0,new TokenSelectListOutputDto + + if (includeDefault == true) { - TokenId = Guid.Empty, - Name = "默认", - IsDisabled = false - }); + tokens.Insert(0, new TokenSelectListOutputDto + { + TokenId = Guid.Empty, + Name = "默认", + IsDisabled = false + }); + } + return tokens; }