From a92511b408d0b27089663bc0c455876bdbbeace1 Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Wed, 3 Nov 2021 20:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/FileController.cs | 6 +++--- .../Controllers/SettingController.cs | 16 ++++++++++------ .../Yi.Framework.Common/Helper/ExcelHelper.cs | 2 +- .../Yi.Framework.WebCore/Init/RedisInit.cs | 16 ++++++++-------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs index 63d8ab79..8da4a2d5 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs @@ -39,7 +39,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public IActionResult Get(string type, string imageNmae) { - var path = Path.Combine($"wwwroot\\{type}", imageNmae); + var path = Path.Combine($"wwwroot/{type}", imageNmae); var stream = System.IO.File.OpenRead(path); var MimeType = Common.Helper.MimeHelper.GetMimeMapping(imageNmae); return new FileStreamResult(stream, MimeType); @@ -55,7 +55,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers { string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); - using (var stream = new FileStream(Path.Combine($"wwwroot\\{type}", filename), FileMode.CreateNew, FileAccess.Write)) + using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write)) { await file.CopyToAsync(stream); } @@ -71,7 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers List header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip","年龄", "个人介绍", "地址", "手机", "角色" }; var filename= Common.Helper.ExcelHelper.CreateExcelFromList(userList,header,_env.ContentRootPath.ToString()); var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename); - return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"\wwwroot\Excel", filename), FileMode.Open),MimeType); + return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"/wwwroot/Excel", filename), FileMode.Open),MimeType); } } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs index a4a0945f..c5a9e7a9 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs @@ -29,7 +29,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers _cacheClientDB = cacheClientDB; } - + /// /// 查 @@ -37,8 +37,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [HttpGet] public Result GetSetting() - { - return Result.Success().SetData( _cacheClientDB.Get(RedisConst.key)); + { + var setDto = Common.Helper.JsonHelper.ParseFormByJson(_cacheClientDB.Get(RedisConst.key)); + return Result.Success().SetData(setDto); } /// @@ -47,11 +48,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpPut] - public Result UpdateSetting(SettingDto settingDto) + public Result UpdateSetting(SettingDto settingDto) { - _cacheClientDB.Set(RedisConst.key, settingDto); + var setDto = Common.Helper.JsonHelper.GetJSON(settingDto); + + _cacheClientDB.Set(RedisConst.key, setDto); return Result.Success(); } } -} + +} \ No newline at end of file diff --git a/Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs b/Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs index b04850f1..8d0f808d 100644 --- a/Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs +++ b/Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs @@ -20,7 +20,7 @@ namespace Yi.Framework.Common.Helper public static string CreateExcelFromList(List dataList, List headers,string evn) { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - string sWebRootFolder = Path.Combine($"{evn}", "wwwroot\\Excel");//如果用浏览器url下载的方式 存放excel的文件夹一定要建在网站首页的同级目录下!!! + string sWebRootFolder = Path.Combine($"{evn}", "wwwroot/Excel");//如果用浏览器url下载的方式 存放excel的文件夹一定要建在网站首页的同级目录下!!! if (!Directory.Exists(sWebRootFolder)) { Directory.CreateDirectory(sWebRootFolder); diff --git a/Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs b/Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs index 25888d21..385b8a9e 100644 --- a/Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs +++ b/Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs @@ -13,16 +13,16 @@ namespace Yi.Framework.WebCore.Init { public static void Seed(CacheClientDB _cacheClientDB) { - + var setDto = Common.Helper.JsonHelper.GetJSON(new SettingDto() + { + ImageList_key = { "默认图片", "默认图片" }, + InitRole_key = "默认角色", + Title_key = "默认标题", + InitIcon_key = "默认头像" + }); if (_cacheClientDB.Get(RedisConst.key)==null) { - _cacheClientDB.Add(RedisConst.key, new SettingDto() - { - ImageList_key = { "默认图片", "默认图片" } , - InitRole_key= "默认角色", - Title_key= "默认标题", - InitIcon_key= "默认头像" - }) ; + _cacheClientDB.Add(RedisConst.key,setDto) ; } Console.WriteLine(nameof(RedisInit) + ":Redis初始成功!");