EPPlus替换成miniExcel

This commit is contained in:
不做码农 2022-12-08 16:53:47 +08:00
parent d32c211aee
commit 1792bb773d
16 changed files with 172 additions and 216 deletions

View File

@ -2,9 +2,9 @@
using Infrastructure.Model; using Infrastructure.Model;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using OfficeOpenXml;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -58,15 +58,15 @@ namespace ZR.Admin.WebApi.Controllers
/// <summary> /// <summary>
/// 导出Excel /// 导出Excel
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path">完整文件路径</param>
/// <param name="fileName"></param> /// <param name="fileName">带扩展文件名</param>
/// <returns></returns> /// <returns></returns>
protected IActionResult ExportExcel(string path, string fileName) protected IActionResult ExportExcel(string path, string fileName)
{ {
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); //IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string fileDir = Path.Combine(webHostEnvironment.WebRootPath, path, fileName); //string fileDir = Path.Combine(webHostEnvironment.WebRootPath, path, fileName);
var stream = ff.File.OpenRead(fileDir); //创建文件流 var stream = ff.File.OpenRead(path); //创建文件流
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName)); return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName));
} }
@ -130,31 +130,19 @@ namespace ZR.Admin.WebApi.Controllers
/// <param name="fileName"></param> /// <param name="fileName"></param>
protected string ExportExcel<T>(List<T> list, string sheetName, string fileName) protected string ExportExcel<T>(List<T> list, string sheetName, string fileName)
{ {
var fileInfo = ExportExcelNew(list, sheetName, fileName); return ExportExcelMini(list, sheetName, fileName).Item1;
return fileInfo.Item1;
} }
protected (string, string) ExportExcelNew<T>(List<T> list, string sheetName, string fileName) protected (string, string) ExportExcelMini<T>(List<T> list, string sheetName, string fileName)
{ {
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}{DateTime.Now:MMddHHmmss}.xlsx"; string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx";
string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName); string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
//调试模式需要加上
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
using (ExcelPackage package = new(new FileInfo(newFileName)))
{
// 添加worksheet
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(sheetName);
//单元格自动适应大小
worksheet.Cells.Style.ShrinkToFit = true;
//全部字段导出
worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
package.Save();
}
return (sFileName, newFileName); MiniExcel.SaveAs(fullPath, list, sheetName: sheetName);
return (sFileName, fullPath);
} }
/// <summary> /// <summary>
@ -170,23 +158,12 @@ namespace ZR.Admin.WebApi.Controllers
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}模板.xlsx"; string sFileName = $"{fileName}模板.xlsx";
string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "importTemplate", sFileName); string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "importTemplate", sFileName);
//调试模式需要加上
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
if (!Directory.Exists(newFileName)) if (!Directory.Exists(newFileName))
{ {
Directory.CreateDirectory(Path.GetDirectoryName(newFileName)); Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
} }
using (ExcelPackage package = new(new FileInfo(newFileName))) MiniExcel.SaveAs(newFileName, list);
{
// 添加worksheet
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(fileName);
//单元格自动适应大小
worksheet.Cells.Style.ShrinkToFit = true;
//全部字段导出
worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
package.SaveAs(stream);
}
return sFileName; return sFileName;
} }
} }

View File

@ -2,13 +2,11 @@ using Infrastructure.Attribute;
using Infrastructure.Enums; using Infrastructure.Enums;
using Infrastructure.Model; using Infrastructure.Model;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic; using MiniExcelLibs;
using System.IO; using SqlSugar;
using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters; using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model; using ZR.Model;
using ZR.Model.System; using ZR.Model.System;
using ZR.Service.System.IService; using ZR.Service.System.IService;
@ -179,7 +177,14 @@ namespace ZR.Admin.WebApi.Controllers.System
[ActionPermissionFilter(Permission = "system:user:import")] [ActionPermissionFilter(Permission = "system:user:import")]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile) public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{ {
IEnumerable<SysUser> users = ExcelHelper<SysUser>.ImportData(formFile.OpenReadStream()); //List<SysUser> users = (List<SysUser>)ExcelHelper<SysUser>.ImportData(formFile.OpenReadStream());
List<SysUser> users = new();
using (var stream = formFile.OpenReadStream())
{
users = stream.Query<SysUser>().ToList();
}
string msg = UserService.ImportUsers(users);
//TODO 业务逻辑,自行插入数据到db //TODO 业务逻辑,自行插入数据到db
return SUCCESS(users); return SUCCESS(users);
@ -213,9 +218,8 @@ namespace ZR.Admin.WebApi.Controllers.System
{ {
var list = UserService.SelectUserList(user, new PagerInfo(1, 10000)); var list = UserService.SelectUserList(user, new PagerInfo(1, 10000));
//调试模式需要加上 var result = ExportExcelMini(list.Result, "user", "用户列表");
string sFileName = ExportExcel(list.Result, "user", "用户列表"); return ExportExcel(result.Item2, result.Item1);
return ExportExcel("export", sFileName);
} }
} }
} }

View File

@ -30,7 +30,6 @@
<PackageReference Include="NLog" Version="5.0.4" /> <PackageReference Include="NLog" Version="5.0.4" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.1.4" /> <PackageReference Include="NLog.Web.AspNetCore" Version="5.1.4" />
<PackageReference Include="Mapster" Version="7.3.0" /> <PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="EPPlus" Version="6.0.5" />
<PackageReference Include="Hei.Captcha" Version="0.3.0" /> <PackageReference Include="Hei.Captcha" Version="0.3.0" />
</ItemGroup> </ItemGroup>

View File

@ -155,8 +155,8 @@ $if(replaceDto.ShowBtnExport)
{ {
return ToResponse(ResultCode.FAIL, "没有要导出的数据"); return ToResponse(ResultCode.FAIL, "没有要导出的数据");
} }
string sFileName = ExportExcel(list, "${genTable.FunctionName}", "${genTable.FunctionName}"); var result = ExportExcelMini(list, "${genTable.FunctionName}", "${genTable.FunctionName}");
return ExportExcel("export", sFileName); return ExportExcel(result.Item2, result.Item1);
} }
$end $end

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using ${options.ModelsNamespace}.Dto; using ${options.ModelsNamespace}.Dto;
using ${options.ModelsNamespace}.Models; using ${options.ModelsNamespace}.Models;
$if(replaceDto.ShowBtnExport) $if(replaceDto.ShowBtnExport)
using OfficeOpenXml.Attributes; using MiniExcelLibs.Attributes;
$end $end
namespace ${options.DtosNamespace}.Dto namespace ${options.DtosNamespace}.Dto
@ -39,9 +39,9 @@ $if(item.IsRequired)
$end $end
$if(replaceDto.ShowBtnExport) $if(replaceDto.ShowBtnExport)
$if(item.IsExport) $if(item.IsExport)
[EpplusTableColumn(Header = "$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}"$if(item.CsharpType == "DateTime"), NumberFormat = "yyyy-MM-dd HH:mm:ss"$end)] [ExcelColumn(Name = "$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}"$if(item.CsharpType == "DateTime"), Format = "yyyy-MM-dd HH:mm:ss"$end)]
$else $else
[EpplusIgnore] [ExcelIgnore]
$end $end
$end $end
public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; } public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; }
@ -50,14 +50,14 @@ $end
$if(genTable.TplCategory == "subNav" && genTable.SubTable != null) $if(genTable.TplCategory == "subNav" && genTable.SubTable != null)
$if(replaceDto.ShowBtnExport) $if(replaceDto.ShowBtnExport)
[EpplusIgnore] [ExcelIgnore]
$end $end
public ${genTable.SubTable.ClassName} ${genTable.SubTable.ClassName} { get; set; } public ${genTable.SubTable.ClassName} ${genTable.SubTable.ClassName} { get; set; }
$end $end
$if(genTable.TplCategory == "subNavMore" && genTable.SubTable != null) $if(genTable.TplCategory == "subNavMore" && genTable.SubTable != null)
$if(replaceDto.ShowBtnExport) $if(replaceDto.ShowBtnExport)
[EpplusIgnore] [ExcelIgnore]
$end $end
public List<${genTable.SubTable.ClassName}> ${genTable.SubTable.ClassName} { get; set; } public List<${genTable.SubTable.ClassName}> ${genTable.SubTable.ClassName} { get; set; }
$end $end

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using OfficeOpenXml;
namespace ZR.Common namespace ZR.Common
{ {
public class ExcelHelper<T> where T : new() public class ExcelHelper<T> where T : new()
@ -13,84 +13,84 @@ namespace ZR.Common
/// </summary> /// </summary>
/// <param name="stream"></param> /// <param name="stream"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> ImportData(Stream stream) //public static IEnumerable<T> ImportData(Stream stream)
{ //{
using ExcelPackage package = new(stream); // using ExcelPackage package = new(stream);
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; // //ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet // ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet
//获取表格的列数和行数 // //获取表格的列数和行数
int colStart = worksheet.Dimension.Start.Column; // int colStart = worksheet.Dimension.Start.Column;
int colEnd = worksheet.Dimension.End.Column; // int colEnd = worksheet.Dimension.End.Column;
int rowStart = worksheet.Dimension.Start.Row; // int rowStart = worksheet.Dimension.Start.Row;
int rowEnd = worksheet.Dimension.End.Row; // int rowEnd = worksheet.Dimension.End.Row;
//int rowCount = worksheet.Dimension.Rows; // //int rowCount = worksheet.Dimension.Rows;
//int ColCount = worksheet.Dimension.Columns; // //int ColCount = worksheet.Dimension.Columns;
List<T> resultList = new(); // List<T> resultList = new();
List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties()); // List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
Dictionary<string, int> dictHeader = new(); // Dictionary<string, int> dictHeader = new();
for (int i = colStart; i < colEnd; i++) // for (int i = colStart; i < colEnd; i++)
{ // {
var name = worksheet.Cells[rowStart, i].Value.ToString(); // var name = worksheet.Cells[rowStart, i].Value?.ToString();
dictHeader[name] = i; // dictHeader[name] = i;
PropertyInfo propertyInfo = MapPropertyInfo(name); // PropertyInfo propertyInfo = MapPropertyInfo(name);
if (propertyInfo != null) // if (propertyInfo != null)
{ // {
propertyInfos.Add(propertyInfo); // propertyInfos.Add(propertyInfo);
} // }
} // }
for (int row = rowStart + 1; row <= rowEnd; row++) // for (int row = rowStart + 1; row <= rowEnd; row++)
{ // {
T result = new(); // T result = new();
foreach (PropertyInfo p in propertyInfos) // foreach (PropertyInfo p in propertyInfos)
{ // {
try // try
{ // {
ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]]; // ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]];
if (cell.Value == null) // if (cell.Value == null)
{ // {
continue; // continue;
} // }
switch (p.PropertyType.Name.ToLower()) // switch (p.PropertyType.Name.ToLower())
{ // {
case "string": // case "string":
p.SetValue(result, cell.GetValue<string>()); // p.SetValue(result, cell.GetValue<string>());
break; // break;
case "int16": // case "int16":
p.SetValue(result, cell.GetValue<short>()); break; // p.SetValue(result, cell.GetValue<short>()); break;
case "int32": // case "int32":
p.SetValue(result, cell.GetValue<int>()); break; // p.SetValue(result, cell.GetValue<int>()); break;
case "int64": // case "int64":
p.SetValue(result, cell.GetValue<long>()); break; // p.SetValue(result, cell.GetValue<long>()); break;
case "decimal": // case "decimal":
p.SetValue(result, cell.GetValue<decimal>()); // p.SetValue(result, cell.GetValue<decimal>());
break; // break;
case "double": // case "double":
p.SetValue(result, cell.GetValue<double>()); break; // p.SetValue(result, cell.GetValue<double>()); break;
case "datetime": // case "datetime":
p.SetValue(result, cell.GetValue<DateTime>()); break; // p.SetValue(result, cell.GetValue<DateTime>()); break;
case "boolean": // case "boolean":
p.SetValue(result, cell.GetValue<bool>()); break; // p.SetValue(result, cell.GetValue<bool>()); break;
case "char": // case "char":
p.SetValue(result, cell.GetValue<string>()); break; // p.SetValue(result, cell.GetValue<string>()); break;
default: // default:
break; // break;
} // }
} // }
catch (KeyNotFoundException ex) // catch (KeyNotFoundException ex)
{ // {
Console.WriteLine("未找到该列将继续循环," + ex.Message); // Console.WriteLine("未找到该列将继续循环," + ex.Message);
continue; // continue;
} // }
} // }
resultList.Add(result); // resultList.Add(result);
} // }
return resultList; // return resultList;
} //}
/// <summary> /// <summary>
/// 查找Excel列名对应的实体属性 /// 查找Excel列名对应的实体属性

View File

@ -4,14 +4,14 @@
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" /> <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="CSRedisCore" Version="3.8.3" /> <PackageReference Include="CSRedisCore" Version="3.8.669" />
<PackageReference Include="EPPlus" Version="6.0.5" /> <PackageReference Include="JinianNet.JNTemplate" Version="2.3.2" />
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.2" /> <PackageReference Include="MailKit" Version="3.4.2" />
<PackageReference Include="MailKit" Version="3.4.2" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" /> <PackageReference Include="MiniExcel" Version="1.29.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />

View File

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using SqlSugar;
using OfficeOpenXml.Attributes;
using Newtonsoft.Json; using Newtonsoft.Json;
using SqlSugar;
using System;
using System.ComponentModel;
namespace ZR.Model.Models namespace ZR.Model.Models
{ {
@ -21,7 +20,6 @@ namespace ZR.Model.Models
/// 空值 : false /// 空值 : false
/// </summary> /// </summary>
[JsonConverter(typeof(ValueToStringConverter))] [JsonConverter(typeof(ValueToStringConverter))]
[EpplusTableColumn(Header = "id")]
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; } public long Id { get; set; }
@ -29,7 +27,7 @@ namespace ZR.Model.Models
/// 描述 : 语言code /// 描述 : 语言code
/// 空值 : false /// 空值 : false
/// </summary> /// </summary>
[EpplusTableColumn(Header = "语言code")] [DisplayName("语言code")]
[SugarColumn(ColumnName = "lang_code")] [SugarColumn(ColumnName = "lang_code")]
public string LangCode { get; set; } public string LangCode { get; set; }
@ -37,7 +35,7 @@ namespace ZR.Model.Models
/// 描述 : 语言key /// 描述 : 语言key
/// 空值 : true /// 空值 : true
/// </summary> /// </summary>
[EpplusTableColumn(Header = "语言key")] [DisplayName("语言key")]
[SugarColumn(ColumnName = "lang_key")] [SugarColumn(ColumnName = "lang_key")]
public string LangKey { get; set; } public string LangKey { get; set; }
@ -45,7 +43,7 @@ namespace ZR.Model.Models
/// 描述 : 名称 /// 描述 : 名称
/// 空值 : false /// 空值 : false
/// </summary> /// </summary>
[EpplusTableColumn(Header = "名称")] [DisplayName("名称")]
[SugarColumn(ColumnName = "lang_name")] [SugarColumn(ColumnName = "lang_name")]
public string LangName { get; set; } public string LangName { get; set; }
@ -53,7 +51,7 @@ namespace ZR.Model.Models
/// 描述 : 添加时间 /// 描述 : 添加时间
/// 空值 : true /// 空值 : true
/// </summary> /// </summary>
[EpplusTableColumn(Header = "添加时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] [DisplayName("添加时间")]
public DateTime? Addtime { get; set; } public DateTime? Addtime { get; set; }
} }
} }

View File

@ -1,60 +1,42 @@
//using Dapper.Contrib.Extensions; using MiniExcelLibs.Attributes;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar; using SqlSugar;
using OfficeOpenXml.Attributes; using System;
namespace ZR.Model.System namespace ZR.Model.System
{ {
[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)] //[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
public class SysBase public class SysBase
{ {
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段 [SugarColumn(IsOnlyIgnoreUpdate = true)]
[JsonProperty(propertyName: "CreateBy")] [JsonProperty(propertyName: "CreateBy")]
[EpplusIgnore] [ExcelIgnore]
public string Create_by { get; set; } public string Create_by { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段 [SugarColumn(IsOnlyIgnoreUpdate = true)]
[JsonProperty(propertyName: "CreateTime")] [JsonProperty(propertyName: "CreateTime")]
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")] [ExcelColumn(Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime Create_time { get; set; } = DateTime.Now; public DateTime Create_time { get; set; } = DateTime.Now;
[JsonIgnore] [JsonIgnore]
[JsonProperty(propertyName: "UpdateBy")] [JsonProperty(propertyName: "UpdateBy")]
[SugarColumn(IsOnlyIgnoreInsert = true)] [SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusIgnore] [ExcelIgnore]
public string Update_by { get; set; } public string Update_by { get; set; }
//[JsonIgnore] //[JsonIgnore]
[SugarColumn(IsOnlyIgnoreInsert = true)]//设置后插入数据不会有此字段 [SugarColumn(IsOnlyIgnoreInsert = true)]
[JsonProperty(propertyName: "UpdateTime")] [JsonProperty(propertyName: "UpdateTime")]
[EpplusIgnore] [ExcelIgnore]
public DateTime? Update_time { get; set; } public DateTime? Update_time { get; set; }
public string Remark { get; set; } public string Remark { get; set; }
/// <summary>
/// 搜索时间起始时间
/// </summary>
/// <summary>
/// Write需穿一个bool值false时insertupdate等操作会忽略此列和Computed的作用差不多看了源码也没发现与Computed有什么不一样的地方有了解的朋友可以赐教下哈
/// ExplicitKey指定此列为主键不自动增长类型例如guidExplicitKey与Key地区别下面会详细讲
/// Key指定此列为主键自动增长主键可忽略忽略后默认查找
/// [Computed]计算属性打上此标签对象地insertupdate等操作会忽略此列
/// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[JsonIgnore] [JsonIgnore]
[EpplusIgnore] [ExcelIgnore]
public DateTime? BeginTime { get; set; } public DateTime? BeginTime { get; set; }
/// <summary>
/// 用于搜索使用
/// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[JsonIgnore] [JsonIgnore]
[EpplusIgnore] [ExcelIgnore]
public DateTime? EndTime { get; set; } public DateTime? EndTime { get; set; }
} }
} }

View File

@ -1,5 +1,4 @@
using OfficeOpenXml.Attributes; using SqlSugar;
using SqlSugar;
namespace ZR.Model.System namespace ZR.Model.System
{ {
@ -26,7 +25,6 @@ namespace ZR.Model.System
/// <summary> /// <summary>
/// 状态 0、正常 1、停用 /// 状态 0、正常 1、停用
/// </summary> /// </summary>
[EpplusIgnore]
public string Status { get; set; } public string Status { get; set; }
/// <summary> /// <summary>
/// 系统内置 Y是 N否 /// 系统内置 Y是 N否

View File

@ -1,5 +1,4 @@
using OfficeOpenXml.Attributes; using SqlSugar;
using SqlSugar;
using System; using System;
namespace ZR.Model.System namespace ZR.Model.System
@ -52,7 +51,6 @@ namespace ZR.Model.System
/// <summary> /// <summary>
/// 访问时间 /// 访问时间
/// </summary> /// </summary>
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime LoginTime { get; set; } = DateTime.Now; public DateTime LoginTime { get; set; } = DateTime.Now;
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public DateTime? BeginTime { get; set; } public DateTime? BeginTime { get; set; }

View File

@ -1,6 +1,7 @@
using OfficeOpenXml.Attributes; using MiniExcelLibs.Attributes;
using SqlSugar; using SqlSugar;
using System; using System;
using System.ComponentModel;
namespace ZR.Model.System namespace ZR.Model.System
{ {
@ -11,78 +12,79 @@ namespace ZR.Model.System
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)] [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long OperId { get; set; } public long OperId { get; set; }
/** 操作模块 */ /** 操作模块 */
[EpplusTableColumn(Header = "操作模块")] [DisplayName("操作模块")]
public string Title { get; set; } public string Title { get; set; }
/** 业务类型0其它 1新增 2修改 3删除 */ /** 业务类型0其它 1新增 2修改 3删除 */
//@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") //@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据")
[EpplusTableColumn(Header = "业务类型")] [DisplayName("业务类型")]
public int BusinessType { get; set; } public int BusinessType { get; set; }
/** 业务类型数组 */ /** 业务类型数组 */
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[EpplusIgnore] [ExcelIgnore]
public int[] BusinessTypes { get; set; } public int[] BusinessTypes { get; set; }
/** 请求方法 */ /** 请求方法 */
[EpplusTableColumn(Header = "请求方法")] [DisplayName("请求方法")]
public string Method { get; set; } public string Method { get; set; }
/** 请求方式 */ /** 请求方式 */
[EpplusTableColumn(Header = "请求方式")] [DisplayName("请求方式")]
public string RequestMethod { get; set; } public string RequestMethod { get; set; }
/** 操作类别0其它 1后台用户 2手机端用户 */ /** 操作类别0其它 1后台用户 2手机端用户 */
//@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") //@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户")
[EpplusTableColumn(Header = "操作类别")] [DisplayName("操作类别")]
public int OperatorType { get; set; } public int OperatorType { get; set; }
/** 操作人员 */ /** 操作人员 */
[EpplusTableColumn(Header = "操作人员")] [DisplayName("操作人员")]
public string OperName { get; set; } public string OperName { get; set; }
/** 部门名称 */ /** 部门名称 */
[EpplusTableColumn(Header = "部门名称")] [DisplayName("部门名称")]
public string DeptName { get; set; } public string DeptName { get; set; }
/** 请求url */ /** 请求url */
[EpplusTableColumn(Header = "请求地址")] [DisplayName("请求地址")]
public string OperUrl { get; set; } public string OperUrl { get; set; }
/** 操作地址 */ /** 操作地址 */
[EpplusTableColumn(Header = "操作地址")] [DisplayName("操作地址")]
public string OperIp { get; set; } public string OperIp { get; set; }
/** 操作地点 */ /** 操作地点 */
[EpplusTableColumn(Header = "操作地点")] [DisplayName("操作地点")]
public string OperLocation { get; set; } public string OperLocation { get; set; }
/** 请求参数 */ /** 请求参数 */
[EpplusTableColumn(Header = "请求参数")] [DisplayName("请求参数")]
public string OperParam { get; set; } public string OperParam { get; set; }
/** 返回参数 */ /** 返回参数 */
[EpplusTableColumn(Header = "返回结果")] [DisplayName("返回结果")]
public string JsonResult { get; set; } public string JsonResult { get; set; }
/** 操作状态0正常 1异常 */ /** 操作状态0正常 1异常 */
[EpplusTableColumn(Header = "状态")] [DisplayName("状态")]
public int Status { get; set; } public int Status { get; set; }
/// <summary> /// <summary>
/// 错误消息 /// 错误消息
/// </summary> /// </summary>
[EpplusTableColumn(Header = "错误消息")] [DisplayName("错误消息")]
public string ErrorMsg { get; set; } public string ErrorMsg { get; set; }
/// <summary> /// <summary>
/// 操作时间 /// 操作时间
/// </summary> /// </summary>
[EpplusTableColumn(Header = "操作时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] [DisplayName("操作时间")]
public DateTime? OperTime { get; set; } public DateTime? OperTime { get; set; }
/// <summary> /// <summary>
/// 操作用时 /// 操作用时
/// </summary> /// </summary>
[DisplayName("操作用时")]
public long Elapsed { get; set; } public long Elapsed { get; set; }
} }
} }

View File

@ -1,5 +1,4 @@
using OfficeOpenXml.Attributes; using SqlSugar;
using SqlSugar;
namespace ZR.Model.System namespace ZR.Model.System
{ {
@ -14,9 +13,7 @@ namespace ZR.Model.System
public long PostId { get; set; } public long PostId { get; set; }
public string PostCode { get; set; } public string PostCode { get; set; }
public string PostName { get; set; } public string PostName { get; set; }
[EpplusIgnore]
public int PostSort { get; set; } public int PostSort { get; set; }
[EpplusIgnore]
public string Status { get; set; } public string Status { get; set; }
} }
} }

View File

@ -1,5 +1,4 @@
using OfficeOpenXml.Attributes; using SqlSugar;
using SqlSugar;
using System; using System;
namespace ZR.Model.System namespace ZR.Model.System
@ -39,7 +38,9 @@ namespace ZR.Model.System
/// </summary> /// </summary>
public string InvokeTarget { get; set; } public string InvokeTarget { get; set; }
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")] /// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
/// <summary> /// <summary>
/// 执行用时,毫秒 /// 执行用时,毫秒

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json; using MiniExcelLibs.Attributes;
using OfficeOpenXml.Attributes; using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -28,12 +28,12 @@ namespace ZR.Model.System
//[JsonProperty(propertyName: "userType")] //[JsonProperty(propertyName: "userType")]
//public string User_type { get; set; } = ""; //public string User_type { get; set; } = "";
[SugarColumn(IsOnlyIgnoreInsert = true)] [SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusIgnore] [ExcelIgnore]
public string Avatar { get; set; } public string Avatar { get; set; }
public string Email { get; set; } public string Email { get; set; }
[JsonIgnore] [JsonIgnore]
[EpplusIgnore] [ExcelIgnore]
public string Password { get; set; } public string Password { get; set; }
/// <summary> /// <summary>
/// 手机号 /// 手机号
@ -47,7 +47,7 @@ namespace ZR.Model.System
/// <summary> /// <summary>
/// 帐号状态0正常 1停用 /// 帐号状态0正常 1停用
/// </summary> /// </summary>
[EpplusIgnore] [ExcelIgnore]
public string Status { get; set; } public string Status { get; set; }
/// <summary> /// <summary>
@ -66,7 +66,7 @@ namespace ZR.Model.System
/// 最后登录时间 /// 最后登录时间
/// </summary> /// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true)] [SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")] [ExcelColumn(Name = "登录日期", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime LoginDate { get; set; } public DateTime LoginDate { get; set; }
/// <summary> /// <summary>
@ -95,17 +95,17 @@ namespace ZR.Model.System
/// 角色id集合 /// 角色id集合
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[EpplusIgnore] [ExcelIgnore]
public long[] RoleIds { get; set; } public long[] RoleIds { get; set; }
/// <summary> /// <summary>
/// 岗位集合 /// 岗位集合
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[EpplusIgnore] [ExcelIgnore]
public int[] PostIds { get; set; } public int[] PostIds { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[EpplusIgnore] [ExcelIgnore]
public List<SysRole> Roles { get; set; } public List<SysRole> Roles { get; set; }
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public string WelcomeMessage public string WelcomeMessage

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="EPPlus" Version="6.0.5" /> <PackageReference Include="MiniExcel" Version="1.29.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.33" /> <PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.33" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />