前端终极完善

This commit is contained in:
橙子
2021-11-03 20:28:45 +08:00
parent 2e4f024928
commit ca815ec53e
15 changed files with 106 additions and 77 deletions

View File

@@ -50,7 +50,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
if ( user_data!=null)
{
var token = MakeJwt.app(new jwtUser() {user=user_data,menuIds= menuList});
return Result.Success().SetData(new { user = new { _user.id, _user.username, _user.introduction, _user.icon, _user.nick }, token });
return Result.Success().SetData(new { user = new { user_data.id, user_data.username, user_data.introduction, user_data.icon, user_data.nick }, token });
}
return Result.Error();
}

View File

@@ -23,28 +23,42 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
_userService = userService;
_env = env;
}
}
[HttpPost]
[Authorize]
public async Task<Result> EditIcon(IFormFile file)
{
var _user = HttpContext.GetCurrentUserInfo();
var user_data = await _userService.GetUserById(_user.id);
var type = "image";
var filename = await Upload(type, file);
user_data.icon = filename;
await _userService.UpdateAsync(user_data);
return Result.Success();
try
{
var _user = HttpContext.GetCurrentUserInfo();
var user_data = await _userService.GetUserById(_user.id);
var type = "image";
var filename = await Upload(type, file);
user_data.icon = filename;
await _userService.UpdateAsync(user_data);
return Result.Success();
}
catch
{
return Result.Error();
}
}
[Route("{type}/{fileNmae}")]
[Route("/api/{type}/{fileName}")]
[HttpGet]
public IActionResult Get(string type, string fileNmae)
public IActionResult Get(string type, string fileName)
{
var path = Path.Combine($"wwwroot\\{type}", fileNmae);
var stream = System.IO.File.OpenRead(path);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileNmae);
return new FileStreamResult(stream, MimeType);
try
{
var path = Path.Combine($"wwwroot/{type}", fileName);
var stream = System.IO.File.OpenRead(path);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileName);
return new FileStreamResult(stream, MimeType);
}
catch
{
return new NotFoundResult();
}
}
/// <summary>
@@ -53,11 +67,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <param name="type"></param>
/// <param name="file"></param>
/// <returns></returns>
private async Task<string> Upload(string type,IFormFile file)
private async Task<string> Upload(string type, IFormFile file)
{
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);
}
@@ -65,15 +78,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return filename;
}
[HttpGet]
public async Task<IActionResult>ExportFile()
[HttpGet]
public async Task<IActionResult> ExportFile()
{
var userdata = await _userService.GetAllEntitiesTrueAsync();
var userList = userdata.ToList();
List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip","年龄", "个人介绍", "地址", "手机", "角色" };
var filename= Common.Helper.ExcelHelper.CreateExcelFromList(userList,header,_env.ContentRootPath.ToString());
List<string> 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);
}
}
}

View File

@@ -103,6 +103,11 @@ namespace Yi.Framework.ApiMicroservice
#endregion
//app.UseErrorHandlingService();
#region
//静态文件注入
#endregion
//app.UseStaticFiles();
#region
//HttpsRedirection注入
#endregion

View File

@@ -15,7 +15,7 @@
"Cors_Enabled": true,
"RabbitMQ_Enabled": false,
"Redis_Enabled": true,
"RedisSeed_Enabled": true,
"RedisSeed_Enabled": false,
"Kafka_Enabled": false,
"MutiDB_Enabled": false,
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -93,7 +93,7 @@ namespace Yi.Framework.Core
{
for (int i = menu_data.children.Count() - 1; i >= 0; i--)
{
menu_data.children = menu_data.children.AsEnumerable().OrderBy(u => u.sort).ToList();
menu_data.children = menu_data.children.AsEnumerable().OrderByDescending(u => u.sort).ToList();
if (menu_data.children != null || menu_data.children.Count() != 0)
{

View File

@@ -16,7 +16,7 @@ namespace Yi.Framework.WebCore.Init
if (_cacheClientDB.Get<SettingDto>(RedisConst.key)==null)
{
Newtonsoft.Json.JsonConvert.SerializeObject();
//Newtonsoft.Json.JsonConvert.SerializeObject();
_cacheClientDB.Add(RedisConst.key, new SettingDto()
{
ImageList_key = { "默认图片", "默认图片" } ,