增加前端配置获取以及更新接口
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
21136f1238
commit
cf45582a40
|
|
@ -127,5 +127,6 @@
|
|||
"DuplicationWindowMs": 500,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": []
|
||||
}
|
||||
},
|
||||
"FrontWebConfig": "222"
|
||||
}
|
||||
|
|
@ -579,6 +579,12 @@
|
|||
<param name="emailConfig"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.Common.DeployConfigService.GetWebConfigInfo">
|
||||
<summary>
|
||||
获取前端配置
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.Service.Common.TU_TR_RSBaseModel.ResearchProgramNo">
|
||||
<summary>
|
||||
方案编号 STUDYID
|
||||
|
|
|
|||
|
|
@ -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<IResponseOutput> 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();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取前端配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<string> 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<IResponseOutput> 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue