From 76b57c5717f8ae51ca63baf04dae9edbbf628c1b Mon Sep 17 00:00:00 2001
From: lq1405 <2769838458@qq.com>
Date: Sat, 22 Feb 2025 15:00:25 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eget=E8=BD=AC=E5=8F=91?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3=20=E6=96=B0=E5=A2=9ELaitool=20=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AE=E4=B8=AD=E7=9A=84=E7=BB=98=E5=9B=BE=E8=AE=BE=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
LMS.Common/Dictionary/AllOptions.cs | 8 +-
LMS.Common/Enum/OptionTypeEnum.cs | 8 ++
LMS.Repository/Forward/SimpleTransferModel.cs | 13 ++++
.../DatabaseConfiguration.cs | 9 +--
LMS.service/Controllers/ForwardController.cs | 16 +++-
LMS.service/Controllers/OptionsController.cs | 7 --
LMS.service/Service/ForwardWordService.cs | 77 +++++++++++++++++--
7 files changed, 118 insertions(+), 20 deletions(-)
diff --git a/LMS.Common/Dictionary/AllOptions.cs b/LMS.Common/Dictionary/AllOptions.cs
index f44015c..5eb2f57 100644
--- a/LMS.Common/Dictionary/AllOptions.cs
+++ b/LMS.Common/Dictionary/AllOptions.cs
@@ -1,4 +1,7 @@
-namespace LMS.Common.Dictionary;
+
+using LMS.Common.Enum;
+
+namespace LMS.Common.Dictionary;
public class AllOptions
{
@@ -7,6 +10,7 @@ public class AllOptions
{ "all", [] },
{ "tts", ["EdgeTTsRoles"] },
{ "software", ["LaitoolHomePage", "LaitoolNotice", "LaitoolUpdateContent","LaitoolVersion"]},
- { "trial" , ["LaiToolTrialDays"] }
+ { "trial" , ["LaiToolTrialDays"] },
+ { "image", [OptionKeyName.LaitoolFluxApiModelList] }
};
}
diff --git a/LMS.Common/Enum/OptionTypeEnum.cs b/LMS.Common/Enum/OptionTypeEnum.cs
index d98c315..8648191 100644
--- a/LMS.Common/Enum/OptionTypeEnum.cs
+++ b/LMS.Common/Enum/OptionTypeEnum.cs
@@ -6,3 +6,11 @@ public enum OptionTypeEnum
JSON = 2,
Number = 3,
}
+
+public static class OptionKeyName
+{
+ ///
+ /// LaiTool Flux API 模型列表的Option Key
+ ///
+ public const string LaitoolFluxApiModelList = "LaitoolFluxApiModelList";
+}
diff --git a/LMS.Repository/Forward/SimpleTransferModel.cs b/LMS.Repository/Forward/SimpleTransferModel.cs
index 4aaa430..6871c54 100644
--- a/LMS.Repository/Forward/SimpleTransferModel.cs
+++ b/LMS.Repository/Forward/SimpleTransferModel.cs
@@ -17,3 +17,16 @@ public class SimpleTransferModel
///
public string dataString { get; set; }
}
+
+public class GetTransferModel
+{
+ ///
+ /// GPT的完整地址
+ ///
+ public string url { get; set; }
+
+ ///
+ /// 对应的API站的使用的APIkey
+ ///
+ public string? APIKey { get; set; }
+}
diff --git a/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs b/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs
index b03d0c8..9bcec72 100644
--- a/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs
+++ b/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs
@@ -1,12 +1,10 @@
-using LMS.DAO;
+using LMS.Common.Enum;
+using LMS.DAO;
using LMS.Repository.DB;
using LMS.Repository.Models.DB;
using LMS.Tools.Extensions;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
-using LMS.Common.Enum;
-using System.Threading;
-using static LMS.Common.Enums.ResponseCodeEnum;
namespace LMS.service.Configuration.InitConfiguration;
@@ -102,7 +100,8 @@ public class DatabaseConfiguration(IServiceProvider serviceProvider) : IHostedSe
new Options { Key = "LaitoolUpdateContent", Value = string.Empty, Type = OptionTypeEnum.String },
new Options { Key = "LaitoolNotice", Value = string.Empty, Type = OptionTypeEnum.String },
new Options { Key = "LaitoolVersion", Value = string.Empty, Type = OptionTypeEnum.String },
- new Options { Key = "LaiToolTrialDays", Value = "2" , Type = OptionTypeEnum.Number}
+ new Options { Key = "LaiToolTrialDays", Value = "2" , Type = OptionTypeEnum.Number},
+ new Options { Key = OptionKeyName.LaitoolFluxApiModelList, Value = "{}" , Type = OptionTypeEnum.JSON }
];
// 遍历所有的配置项,如果没有则添加
diff --git a/LMS.service/Controllers/ForwardController.cs b/LMS.service/Controllers/ForwardController.cs
index 805d646..267dc55 100644
--- a/LMS.service/Controllers/ForwardController.cs
+++ b/LMS.service/Controllers/ForwardController.cs
@@ -82,7 +82,7 @@ public class ForwardController(ForwardWordService forwardWordService) : Controll
#endregion
- #region 普通转发接口,直接转发,不要系统数据
+ #region Post 直接转发接口
///
/// 转发所有的OpenAI格式的AI请求
@@ -100,4 +100,18 @@ public class ForwardController(ForwardWordService forwardWordService) : Controll
}
#endregion
+
+ #region Get直接转发接口
+
+ [HttpPost]
+ public async Task>> GetTransfer([FromBody] GetTransferModel getTransferModel)
+ {
+ if (!ModelState.IsValid)
+ {
+ return APIResponseModel