diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index ce43480c8..50a4c7090 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -1,32 +1,28 @@ { - // 日志信息 "Logging": { - // 日志等级 "LogLevel": { - // 默认日志等级 "Default": "Information", - // 调试日志等级 "Microsoft": "Warning", - // ASP.NET Core 日志等级 "Microsoft.Hosting.Lifetime": "Information" } }, - // 数据库链接字符串 "ConnectionStrings": { - // 本地数据库链接字符串 "RemoteNew": "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", - // Hangfire 定时任务数据库链接字符串 "Hangfire": "Server=106.14.89.110,1435;Database=Test_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" }, "WeComNoticeConfig": { "IsOpenWeComNotice": true, - "WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322 - "APINoticeUserList": [ "u", "wait..." ], - "VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ] + "WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", + "APINoticeUserList": [ + "u", + "wait..." + ], + "VueNoticeUserList": [ + "wangxiaoshuang", + "6b7717a31647293621b97b96f74e6f3d" + ] }, - // 对象存储服务配置 "ObjectStoreService": { - // 使用的对象存储服务类型 "ObjectStoreUse": "AliyunOSS", "IsOpenStoreSync": true, "ApiDeployRegion": "CN", @@ -48,168 +44,88 @@ "IsOpenSync": true } ], - // 阿里云对象存储服务的配置 "AliyunOSS": { - // 阿里云 OSS 的 Region ID "RegionId": "cn-shanghai", - // 阿里云 OSS 的内部访问端点 "InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", - // 阿里云 OSS 的外部访问端点 "EndPoint": "https://oss-cn-shanghai.aliyuncs.com", - // 阿里云 OSS 的访问密钥 ID "AccessKeyId": "LTAI5tRRZehUp2V9pyTPtAJm", - // 阿里云 OSS 的访问密钥 Secret "AccessKeySecret": "FLizxkHsMm4CGYHtkV8E3PNJJZU7oV", - // 阿里云 OSS 的角色 ARN "RoleArn": "acs:ram::1899121822495495:role/dev-oss-access", - // 阿里云 OSS 的Bucket名称 "BucketName": "zy-irc-test-store", - // 阿里云 OSS 的访问端点 "ViewEndpoint": "https://zy-irc-test-dev-cache.oss-cn-shanghai.aliyuncs.com", - // 阿里云 OSS 的预览端点 "Region": "oss-cn-shanghai", - // 阿里云 OSS 的临时访问凭证有效时间(秒) "DurationSeconds": 7200, - // 阿里云 OSS 的预览端点 "PreviewEndpoint": "https://test-oss.test.extimaging.com" }, - // MinIO 对象存储服务的配置 "MinIO": { - // MinIO 的访问端点 "EndPoint": "hir-oss.test.extimaging.com", - // MinIO 的端口 "Port": "443", - // 是否使用 SSL "UseSSL": true, - // MinIO 的角色 ARN "AccessKey": "fbStsVYCIPKHQneeqMwD", - // MinIO 的访问密钥 "SecretKey": "TzgvyA3zGXMUnpilJNUlyMYHfosl1hBMl6lxPmjy", - // MinIO 的BucketName "BucketName": "irc-test", - // MinIO 的访问端点 "ViewEndpoint": "https://hir-oss.test.extimaging.com/irc-test" }, - // AWS S3 对象存储服务的配置 "AWS": { - // AWS S3 的Region "Region": "us-east-1", - // AWS S3 的内部访问端点 "EndPoint": "s3.us-east-1.amazonaws.com", - // 是否使用 SSL "UseSSL": true, - // AWS S3 的角色 ARN "RoleArn": "arn:aws:iam::471112624751:role/uat_s3_access", - // AWS S3 的访问密钥 ID "AccessKeyId": "AKIAW3MEAFJX7IPXISP4", - // AWS S3 的访问密钥 Secret "SecretAccessKey": "Pgrg3le5jPxZQ7MR1yYNS30J0XRyJeKVyIIjElXc", - // AWS S3 的Bucket名称 "BucketName": "ei-med-s3-lili-uat-store", - // AWS S3 的访问端点 "ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com", - // AWS S3 的持续数秒 "DurationSeconds": 7200 } }, - // 系统配置 "BasicSystemConfig": { - // 启用质控风险控制功能 "QCRiskControl": true, - // 打开用户复杂密码 "OpenUserComplexPassword": false, - // 是否在开始工作前强制签署电子知情同意书 "OpenSignDocumentBeforeWork": false, - // 是否启用登录失败次数限制(防暴力破解) "OpenLoginLimit": false, - // 连续登录失败多少次后触发锁定 "LoginMaxFailCount": 5, - // 触发锁定后账号锁定时长(分钟) "LoginFailLockMinutes": 1, - // 无操作自动登出的超时时间(分钟) "AutoLoginOutMinutes": 10, - // 是否启用多因子登录认证(MFA) "OpenLoginMFA": false, - // 连续阅片的最长工作时间(分钟),超时后强制休息 "ContinuousReadingTimeMin": 120, - // 强制休息时长(分钟) "ReadingRestTimeMin": 10, - // 是否强制用户定期修改密码 "IsNeedChangePassWord": true, - // 密码有效期(天),到期后必须修改 "ChangePassWordDays": 90, - // 模板类型 1 Elevate(LiLi) 2 Extensive(展影) "TemplateType": 2, - // 是否打开项目关联删除 - "OpenTrialRelationDelete": true, - // 转换PDF服务配置 + "OpenTrialRelationDelete": false, "ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf", - //MFA免验证发送天数 "UserMFAVerifyMinutes": 1440 }, - // 邮件服务配置(用于系统通知、找回密码、错误报警等) "SystemEmailSendConfig": { - - // 企业邮箱SMTP服务器地址 "Host": "smtp.qiye.aliyun.com", - // SMTP端口 "Port": 465, - "Imap": "imap.qiye.aliyun.com", "ImapPort": 993, - - // 发件人邮箱地址 "FromEmail": "test@extimaging.com", - // 发件人显示名称 "FromName": "Test EIC Imaging System", - // SMTP授权码 "AuthorizationCode": "SHzyyl2021", - // 系统对外访问地址 "SiteUrl": "http://irc.test.extimaging.com/login", - - - // 系统简称 - 一致性核查使用 "SystemShortName": "IRC", - // 组织英文名称-添加用户默认值 "OrganizationName": "ExtImaging", - // 组织中文名称 "OrganizationNameCN": "ExtImaging", - "PlatformName": "EICS", "PlatformNameCN": "展影云平台", - // 公司英文全称 "CompanyName": "Extensive Imaging", - // 公司中文全称 "CompanyNameCN": "上海展影医疗科技有限公司", - // 公司英文简称 "CompanyShortName": "Extensive Imaging", - // 公司中文简称 "CompanyShortNameCN": "展影医疗", - - // 是否为国际版环境 方便前端区分,用于区分lili 还是irc 做一些事情 "IsEnv_US": false, - // 邮箱格式校验正则表达式 "EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", - - //后端周期性邮件默认语言 "CronEmailDefaultCulture": "zh-CN" }, - // PACS 连接配置 "SystemPacsConfig": { - // PACS服务器端口 "Port": "11113", - // PACS服务器IP地址 "IP": "106.14.89.110" }, - // 重复请求配置 "RequestDuplicationOptions": { - // 是否启用重复请求检测 "IsEnabled": true, - // 重复请求时间窗口(毫秒) "DuplicationWindowMs": 500, - // 缓存请求时间(秒) "CacheTimeSeconds": 5, - "ExcludedPaths": [ - ] + "ExcludedPaths": [] } -} +} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs index f6e85f0b3..28f875901 100644 --- a/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/DeployConfigService.cs @@ -4,6 +4,7 @@ using Medallion.Threading; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; @@ -16,7 +17,7 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Application.Service.Common; [ApiExplorerSettings(GroupName = "Common")] -public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _distributedLockProvider, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService +public class DeployConfigService(IMapper _mapper, IConfiguration _configuration, IDistributedLockProvider _distributedLockProvider, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService { /// @@ -26,7 +27,18 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist /// public async Task GetSystemBasicConfigInfo([FromServices] IOptionsMonitor options) { - return options.CurrentValue; + //var config = _configuration.GetSection("BasicSystemConfig").Get(); + //return config; + + + var path = Path.Combine( _hostEnvironment.ContentRootPath,$"appsettings.{_hostEnvironment.EnvironmentName}.json"); + + var json = File.ReadAllText(path); + + var obj = JObject.Parse(json); + + return obj["BasicSystemConfig"]!.ToObject()!; + } /// @@ -37,7 +49,8 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist [HttpPost] public async Task UpdateSystemBasicConfig(ServiceVerifyConfigOption basicSystemConfigOption) { - var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + //var path = $"appsettings.{_hostEnvironment.EnvironmentName}.json"; + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); var @lock = _distributedLockProvider.CreateLock("WriteConfigFile"); @@ -74,7 +87,6 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist string result = obj.ToString(); System.IO.File.WriteAllText(path, result); - await Task.Delay(1000); } @@ -88,7 +100,18 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist /// public async Task GetEmailConfigInfo([FromServices] IOptionsMonitor options) { - return options.CurrentValue; + //两种方式都有问题 + //var config = _configuration.GetSection("BasicSystemConfig").Get(); + //return config; + //return options.CurrentValue; + + var path = Path.Combine(_hostEnvironment.ContentRootPath, $"appsettings.{_hostEnvironment.EnvironmentName}.json"); + + var json = File.ReadAllText(path); + + var obj = JObject.Parse(json); + + return obj["SystemEmailSendConfig"]!.ToObject()!; } @@ -100,7 +123,8 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist [HttpPost] public async Task UpdateSystemEmailConfig(SystemEmailSendConfig emailConfig) { - var path = $"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"); @@ -141,7 +165,6 @@ public class DeployConfigService(IMapper _mapper, IDistributedLockProvider _dist string result = obj.ToString(); System.IO.File.WriteAllText(path, result); - await Task.Delay(1000); }