333
This commit is contained in:
parent
45cb674557
commit
b27ccd121c
|
|
@ -202,64 +202,5 @@ namespace ZR.Admin.WebApi.Controllers
|
||||||
return DownFile(fullPath, fileName);
|
return DownFile(fullPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化种子数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clean">是否清空数据</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet]
|
|
||||||
[AllowAnonymous]
|
|
||||||
[ActionPermissionFilter(Permission = "common")]
|
|
||||||
[Log(BusinessType = BusinessType.INSERT, Title = "初始化数据")]
|
|
||||||
public IActionResult InitSeedData(bool clean = false)
|
|
||||||
{
|
|
||||||
if (!WebHostEnvironment.IsDevelopment())
|
|
||||||
{
|
|
||||||
return ToResponse(ResultCode.CUSTOM_ERROR, "导入数据失败,请在开发模式下初始化");
|
|
||||||
}
|
|
||||||
var path = Path.Combine(WebHostEnvironment.WebRootPath, "data.xlsx");
|
|
||||||
SeedDataService seedDataService = new();
|
|
||||||
var result = seedDataService.InitSeedData(path, clean);
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
foreach (var item in result)
|
|
||||||
{
|
|
||||||
Console.WriteLine(item);
|
|
||||||
}
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
|
||||||
return SUCCESS(new
|
|
||||||
{
|
|
||||||
result
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet]
|
|
||||||
[AllowAnonymous]
|
|
||||||
[ActionPermissionFilter(Permission = "common")]
|
|
||||||
[Log(BusinessType = BusinessType.INSERT, Title = "初始化数据")]
|
|
||||||
public IActionResult UpdateSeedData()
|
|
||||||
{
|
|
||||||
if (!WebHostEnvironment.IsDevelopment())
|
|
||||||
{
|
|
||||||
return ToResponse(ResultCode.CUSTOM_ERROR, "导入数据失败,请在开发模式下初始化");
|
|
||||||
}
|
|
||||||
var path = Path.Combine(WebHostEnvironment.WebRootPath, "data.xlsx");
|
|
||||||
SeedDataService seedDataService = new();
|
|
||||||
|
|
||||||
var sysNotice = MiniExcel.Query<SysNotice>(path, sheetName: "notice").ToList();
|
|
||||||
var result = seedDataService.InitNoticeData(sysNotice);
|
|
||||||
|
|
||||||
var sysMenu = MiniExcel.Query<SysMenu>(path, sheetName: "menu").Where(f => f.MenuId >= 1104).ToList();
|
|
||||||
var result5 = seedDataService.InitMenuData(sysMenu);
|
|
||||||
|
|
||||||
return SUCCESS(new
|
|
||||||
{
|
|
||||||
result,
|
|
||||||
result5
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user