From cf45582a40bd71756f6a5feffb9c9d4e92af4c5e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 10 Aug 2026 13:39:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=8E=B7=E5=8F=96=E4=BB=A5=E5=8F=8A=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Test_IRC.json | 3 +- .../IRaCIS.Core.Application.xml | 6 +++ .../Service/Common/DeployConfigService.cs | 51 ++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index 50a4c7090..fae372b3d 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -127,5 +127,6 @@ "DuplicationWindowMs": 500, "CacheTimeSeconds": 5, "ExcludedPaths": [] - } + }, + "FrontWebConfig": "222" } \ No newline at end of file diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a348a926f..f58fa89d5 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -579,6 +579,12 @@ + + + 获取前端配置 + + + 方案编号 STUDYID diff --git a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs index 28f875901..c27b4d256 100644 --- a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs @@ -31,7 +31,7 @@ public class DeployConfigService(IMapper _mapper, IConfiguration _configuration, //return config; - var path = Path.Combine( _hostEnvironment.ContentRootPath,$"appsettings.{_hostEnvironment.EnvironmentName}.json"); + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); var json = File.ReadAllText(path); @@ -123,7 +123,7 @@ public class DeployConfigService(IMapper _mapper, IConfiguration _configuration, [HttpPost] public async Task UpdateSystemEmailConfig(SystemEmailSendConfig emailConfig) { - var path = Path.Combine(_hostEnvironment.ContentRootPath,$"appsettings.{_hostEnvironment.EnvironmentName}.json"); + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); //var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; var @lock = _distributedLockProvider.CreateLock("WriteConfigFile"); @@ -171,4 +171,51 @@ public class DeployConfigService(IMapper _mapper, IConfiguration _configuration, return ResponseOutput.Ok(); } + + /// + /// 获取前端配置 + /// + /// + [AllowAnonymous] + public async Task GetWebConfigInfo() + { + + + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); + + var json = File.ReadAllText(path); + + var obj = JObject.Parse(json); + + return obj["FrontWebConfig"]!.ToString(); + } + + + public async Task UpdateWebConfigInfo(string configStr) + { + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); + //var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + + var @lock = _distributedLockProvider.CreateLock("WriteConfigFile"); + + using (await @lock.AcquireAsync()) + { + string text = System.IO.File.ReadAllText(path); + // 修改 + JObject obj = JObject.Parse(text); + + // SystemEmailSendConfig 相关配置 + obj["FrontWebConfig"] = configStr; + + // 重新写入appsettings.json + string result = obj.ToString(); + + System.IO.File.WriteAllText(path, result); + + } + + return ResponseOutput.Ok(); + } + + }