同步
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Get(string type, string imageNmae)
|
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 stream = System.IO.File.OpenRead(path);
|
||||||
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(imageNmae);
|
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(imageNmae);
|
||||||
return new FileStreamResult(stream, MimeType);
|
return new FileStreamResult(stream, MimeType);
|
||||||
@@ -55,7 +55,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
|
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);
|
await file.CopyToAsync(stream);
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip","年龄", "个人介绍", "地址", "手机", "角色" };
|
List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip","年龄", "个人介绍", "地址", "手机", "角色" };
|
||||||
var filename= Common.Helper.ExcelHelper.CreateExcelFromList(userList,header,_env.ContentRootPath.ToString());
|
var filename= Common.Helper.ExcelHelper.CreateExcelFromList(userList,header,_env.ContentRootPath.ToString());
|
||||||
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
_cacheClientDB = cacheClientDB;
|
_cacheClientDB = cacheClientDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查
|
/// 查
|
||||||
@@ -37,8 +37,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Result GetSetting()
|
public Result GetSetting()
|
||||||
{
|
{
|
||||||
return Result.Success().SetData( _cacheClientDB.Get<SettingDto>(RedisConst.key));
|
var setDto = Common.Helper.JsonHelper.ParseFormByJson<SettingDto>(_cacheClientDB.Get<string>(RedisConst.key));
|
||||||
|
return Result.Success().SetData(setDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -47,11 +48,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <param name="settingDto"></param>
|
/// <param name="settingDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public Result UpdateSetting(SettingDto settingDto)
|
public Result UpdateSetting(SettingDto settingDto)
|
||||||
{
|
{
|
||||||
_cacheClientDB.Set(RedisConst.key, settingDto);
|
var setDto = Common.Helper.JsonHelper.GetJSON<SettingDto>(settingDto);
|
||||||
|
|
||||||
|
_cacheClientDB.Set(RedisConst.key, setDto);
|
||||||
return Result.Success();
|
return Result.Success();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ namespace Yi.Framework.Common.Helper
|
|||||||
public static string CreateExcelFromList<T>(List<T> dataList, List<string> headers,string evn)
|
public static string CreateExcelFromList<T>(List<T> dataList, List<string> headers,string evn)
|
||||||
{
|
{
|
||||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
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))
|
if (!Directory.Exists(sWebRootFolder))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(sWebRootFolder);
|
Directory.CreateDirectory(sWebRootFolder);
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ namespace Yi.Framework.WebCore.Init
|
|||||||
{
|
{
|
||||||
public static void Seed(CacheClientDB _cacheClientDB)
|
public static void Seed(CacheClientDB _cacheClientDB)
|
||||||
{
|
{
|
||||||
|
var setDto = Common.Helper.JsonHelper.GetJSON<SettingDto>(new SettingDto()
|
||||||
|
{
|
||||||
|
ImageList_key = { "默认图片", "默认图片" },
|
||||||
|
InitRole_key = "默认角色",
|
||||||
|
Title_key = "默认标题",
|
||||||
|
InitIcon_key = "默认头像"
|
||||||
|
});
|
||||||
if (_cacheClientDB.Get<SettingDto>(RedisConst.key)==null)
|
if (_cacheClientDB.Get<SettingDto>(RedisConst.key)==null)
|
||||||
{
|
{
|
||||||
_cacheClientDB.Add(RedisConst.key, new SettingDto()
|
_cacheClientDB.Add(RedisConst.key,setDto) ;
|
||||||
{
|
|
||||||
ImageList_key = { "默认图片", "默认图片" } ,
|
|
||||||
InitRole_key= "默认角色",
|
|
||||||
Title_key= "默认标题",
|
|
||||||
InitIcon_key= "默认头像"
|
|
||||||
}) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine(nameof(RedisInit) + ":Redis初始成功!");
|
Console.WriteLine(nameof(RedisInit) + ":Redis初始成功!");
|
||||||
|
|||||||
Reference in New Issue
Block a user