From 867ae34dd83dfbd2f45b53d373aa0287dfb418fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Sun, 10 Apr 2022 10:24:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=AE=BF=E9=97=AE=E8=B7=AF=E5=BE=84=E8=AF=A5=E4=BB=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/System/SysConfigController.cs | 2 +- ZR.Service/System/SysFileService.cs | 9 +++++---- document/admin-mysql.sql | 1 + document/admin-sqlserver.sql | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs index 5e47b9d..43e11a6 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs @@ -105,7 +105,7 @@ namespace ZR.Admin.WebApi.Controllers throw new CustomException("请求参数错误"); } //从 Dto 映射到 实体 - var model = parm.Adapt().ToCreate(); + var model = parm.Adapt().ToCreate(HttpContext); return SUCCESS(_SysConfigService.Insert(model, it => new { diff --git a/ZR.Service/System/SysFileService.cs b/ZR.Service/System/SysFileService.cs index a774d7d..7421893 100644 --- a/ZR.Service/System/SysFileService.cs +++ b/ZR.Service/System/SysFileService.cs @@ -23,11 +23,11 @@ namespace ZR.Service.System public class SysFileService : BaseService, ISysFileService { private string domainUrl = AppSettings.GetConfig("ALIYUN_OSS:domainUrl"); - private readonly SysFileRepository SysFileRepository; + private readonly ISysConfigService SysConfigService; private OptionsSetting OptionsSetting; - public SysFileService(SysFileRepository repository, IOptions options) + public SysFileService(ISysConfigService sysConfigService, IOptions options) { - SysFileRepository = repository; + SysConfigService = sysConfigService; OptionsSetting = options.Value; } @@ -53,7 +53,8 @@ namespace ZR.Service.System { await formFile.CopyToAsync(stream);//await 不能少 } - string accessPath = string.Concat(OptionsSetting.Upload.UploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName); + string uploadUrl = SysConfigService.GetSysConfigByKey("sys.file.uploadUrl")?.ConfigValue ?? OptionsSetting.Upload.UploadUrl; + string accessPath = string.Concat(uploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName); SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, userName) { StoreType = (int)Infrastructure.Enums.StoreType.LOCAL, diff --git a/document/admin-mysql.sql b/document/admin-mysql.sql index 9de1c29..31a599c 100644 --- a/document/admin-mysql.sql +++ b/document/admin-mysql.sql @@ -679,6 +679,7 @@ insert into sys_config values(1, '主框架页-默认皮肤样式名称', 's insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, '初始化密码 123456' ); insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, '深色主题theme-dark,浅色主题theme-light' ); insert into sys_config values(4, '账号自助-验证码开关', 'sys.account.captchaOnOff', 'true', 'Y', 'admin', sysdate(), '', null, '是否开启验证码功能(off、关闭,1、动态验证码 2、动态gif泡泡 3、泡泡 4、静态验证码)'); +INSERT INTO `sys_config`(`configId`, `configName`, `configKey`, `configValue`, `configType`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (5, '本地文件上传访问域名', 'sys.file.uploadurl', 'http://localhost:8888', 'Y', '', '2022-04-10 10:11:27', '', NULL, NULL); -- ---------------------------- -- 18、代码生成业务表 diff --git a/document/admin-sqlserver.sql b/document/admin-sqlserver.sql index 7175eb6..c116fd4 100644 --- a/document/admin-sqlserver.sql +++ b/document/admin-sqlserver.sql @@ -697,6 +697,8 @@ insert into sys_config values('主框架页-默认皮肤样式名称', 'sys. insert into sys_config values('用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', GETDATE(), '', null, '初始化密码 123456' ); insert into sys_config values('主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', GETDATE(), '', null, '深色主题theme-dark,浅色主题theme-light' ); insert into sys_config values('账号自助-验证码开关', 'sys.account.captchaOnOff', '1', 'Y', 'admin', GETDATE(), '', null, '开启验证码功能(off、关闭,1、动态验证码 2、动态gif泡泡 3、泡泡 4、静态验证码)'); +INSERT INTO sys_config VALUES('本地文件上传访问域名', 'sys.file.uploadurl', 'http://localhost:8888', 'Y', 'admin', GETDATE(), '', NULL, NULL); + GO -- ----------------------------