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 -- ----------------------------