diff --git a/ZR.Admin.WebApi/Controllers/BaseController.cs b/ZR.Admin.WebApi/Controllers/BaseController.cs index 9c27c0a..2f49601 100644 --- a/ZR.Admin.WebApi/Controllers/BaseController.cs +++ b/ZR.Admin.WebApi/Controllers/BaseController.cs @@ -2,9 +2,9 @@ using Infrastructure.Model; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using MiniExcelLibs; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -using OfficeOpenXml; using System; using System.Collections.Generic; using System.IO; @@ -58,15 +58,15 @@ namespace ZR.Admin.WebApi.Controllers /// /// 导出Excel /// - /// - /// + /// 完整文件路径 + /// 带扩展文件名 /// protected IActionResult ExportExcel(string path, string fileName) { - IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); - string fileDir = Path.Combine(webHostEnvironment.WebRootPath, path, fileName); + //IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); + //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)); } @@ -130,31 +130,19 @@ namespace ZR.Admin.WebApi.Controllers /// protected string ExportExcel(List list, string sheetName, string fileName) { - var fileInfo = ExportExcelNew(list, sheetName, fileName); - - return fileInfo.Item1; + return ExportExcelMini(list, sheetName, fileName).Item1; } - protected (string, string) ExportExcelNew(List list, string sheetName, string fileName) + protected (string, string) ExportExcelMini(List list, string sheetName, string fileName) { IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); - string sFileName = $"{fileName}{DateTime.Now:MMddHHmmss}.xlsx"; - string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName); - //调试模式需要加上 - ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - 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(); - } + string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx"; + string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName); + + Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); - return (sFileName, newFileName); + MiniExcel.SaveAs(fullPath, list, sheetName: sheetName); + return (sFileName, fullPath); } /// @@ -170,23 +158,12 @@ namespace ZR.Admin.WebApi.Controllers IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); string sFileName = $"{fileName}模板.xlsx"; string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "importTemplate", sFileName); - //调试模式需要加上 - ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + if (!Directory.Exists(newFileName)) { Directory.CreateDirectory(Path.GetDirectoryName(newFileName)); } - using (ExcelPackage package = new(new FileInfo(newFileName))) - { - // 添加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); - } - + MiniExcel.SaveAs(newFileName, list); return sFileName; } } diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs index d35200d..4823274 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs @@ -2,13 +2,11 @@ using Infrastructure.Attribute; using Infrastructure.Enums; using Infrastructure.Model; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using System.IO; +using MiniExcelLibs; +using SqlSugar; using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; -using ZR.Common; using ZR.Model; using ZR.Model.System; using ZR.Service.System.IService; @@ -179,7 +177,14 @@ namespace ZR.Admin.WebApi.Controllers.System [ActionPermissionFilter(Permission = "system:user:import")] public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile) { - IEnumerable users = ExcelHelper.ImportData(formFile.OpenReadStream()); + //List users = (List)ExcelHelper.ImportData(formFile.OpenReadStream()); + List users = new(); + using (var stream = formFile.OpenReadStream()) + { + users = stream.Query().ToList(); + } + + string msg = UserService.ImportUsers(users); //TODO 业务逻辑,自行插入数据到db return SUCCESS(users); @@ -213,9 +218,8 @@ namespace ZR.Admin.WebApi.Controllers.System { var list = UserService.SelectUserList(user, new PagerInfo(1, 10000)); - //调试模式需要加上 - string sFileName = ExportExcel(list.Result, "user", "用户列表"); - return ExportExcel("export", sFileName); + var result = ExportExcelMini(list.Result, "user", "用户列表"); + return ExportExcel(result.Item2, result.Item1); } } } diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index 5b9cbcc..3eb1973 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -30,7 +30,6 @@ - diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt index 1fb2b44..6588647 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt @@ -155,8 +155,8 @@ $if(replaceDto.ShowBtnExport) { return ToResponse(ResultCode.FAIL, "没有要导出的数据"); } - string sFileName = ExportExcel(list, "${genTable.FunctionName}", "${genTable.FunctionName}"); - return ExportExcel("export", sFileName); + var result = ExportExcelMini(list, "${genTable.FunctionName}", "${genTable.FunctionName}"); + return ExportExcel(result.Item2, result.Item1); } $end diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt index 156e78b..88b1f8e 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt @@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations; using ${options.ModelsNamespace}.Dto; using ${options.ModelsNamespace}.Models; $if(replaceDto.ShowBtnExport) -using OfficeOpenXml.Attributes; +using MiniExcelLibs.Attributes; $end namespace ${options.DtosNamespace}.Dto @@ -39,9 +39,9 @@ $if(item.IsRequired) $end $if(replaceDto.ShowBtnExport) $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 - [EpplusIgnore] + [ExcelIgnore] $end $end public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; } @@ -50,14 +50,14 @@ $end $if(genTable.TplCategory == "subNav" && genTable.SubTable != null) $if(replaceDto.ShowBtnExport) - [EpplusIgnore] + [ExcelIgnore] $end public ${genTable.SubTable.ClassName} ${genTable.SubTable.ClassName} { get; set; } $end $if(genTable.TplCategory == "subNavMore" && genTable.SubTable != null) $if(replaceDto.ShowBtnExport) - [EpplusIgnore] + [ExcelIgnore] $end public List<${genTable.SubTable.ClassName}> ${genTable.SubTable.ClassName} { get; set; } $end diff --git a/ZR.Common/ExcelHelper.cs b/ZR.Common/ExcelHelper.cs index d40a98a..309b725 100644 --- a/ZR.Common/ExcelHelper.cs +++ b/ZR.Common/ExcelHelper.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using OfficeOpenXml; + namespace ZR.Common { public class ExcelHelper where T : new() @@ -13,84 +13,84 @@ namespace ZR.Common /// /// /// - public static IEnumerable ImportData(Stream stream) - { - using ExcelPackage package = new(stream); - ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet - //获取表格的列数和行数 + //public static IEnumerable ImportData(Stream stream) + //{ + // using ExcelPackage package = new(stream); + // //ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + // ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet + // //获取表格的列数和行数 - int colStart = worksheet.Dimension.Start.Column; - int colEnd = worksheet.Dimension.End.Column; - int rowStart = worksheet.Dimension.Start.Row; - int rowEnd = worksheet.Dimension.End.Row; - //int rowCount = worksheet.Dimension.Rows; - //int ColCount = worksheet.Dimension.Columns; + // int colStart = worksheet.Dimension.Start.Column; + // int colEnd = worksheet.Dimension.End.Column; + // int rowStart = worksheet.Dimension.Start.Row; + // int rowEnd = worksheet.Dimension.End.Row; + // //int rowCount = worksheet.Dimension.Rows; + // //int ColCount = worksheet.Dimension.Columns; - List resultList = new(); - List propertyInfos = new();// new(typeof(T).GetProperties()); - Dictionary dictHeader = new(); - for (int i = colStart; i < colEnd; i++) - { - var name = worksheet.Cells[rowStart, i].Value.ToString(); - dictHeader[name] = i; + // List resultList = new(); + // List propertyInfos = new();// new(typeof(T).GetProperties()); + // Dictionary dictHeader = new(); + // for (int i = colStart; i < colEnd; i++) + // { + // var name = worksheet.Cells[rowStart, i].Value?.ToString(); + // dictHeader[name] = i; - PropertyInfo propertyInfo = MapPropertyInfo(name); - if (propertyInfo != null) - { - propertyInfos.Add(propertyInfo); - } - } - for (int row = rowStart + 1; row <= rowEnd; row++) - { - T result = new(); + // PropertyInfo propertyInfo = MapPropertyInfo(name); + // if (propertyInfo != null) + // { + // propertyInfos.Add(propertyInfo); + // } + // } + // for (int row = rowStart + 1; row <= rowEnd; row++) + // { + // T result = new(); - foreach (PropertyInfo p in propertyInfos) - { - try - { - ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]]; - if (cell.Value == null) - { - continue; - } - switch (p.PropertyType.Name.ToLower()) - { - case "string": - p.SetValue(result, cell.GetValue()); - break; - case "int16": - p.SetValue(result, cell.GetValue()); break; - case "int32": - p.SetValue(result, cell.GetValue()); break; - case "int64": - p.SetValue(result, cell.GetValue()); break; - case "decimal": - p.SetValue(result, cell.GetValue()); - break; - case "double": - p.SetValue(result, cell.GetValue()); break; - case "datetime": - p.SetValue(result, cell.GetValue()); break; - case "boolean": - p.SetValue(result, cell.GetValue()); break; - case "char": - p.SetValue(result, cell.GetValue()); break; - default: - break; - } - } - catch (KeyNotFoundException ex) - { - Console.WriteLine("未找到该列将继续循环," + ex.Message); - continue; - } - } - resultList.Add(result); - } + // foreach (PropertyInfo p in propertyInfos) + // { + // try + // { + // ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]]; + // if (cell.Value == null) + // { + // continue; + // } + // switch (p.PropertyType.Name.ToLower()) + // { + // case "string": + // p.SetValue(result, cell.GetValue()); + // break; + // case "int16": + // p.SetValue(result, cell.GetValue()); break; + // case "int32": + // p.SetValue(result, cell.GetValue()); break; + // case "int64": + // p.SetValue(result, cell.GetValue()); break; + // case "decimal": + // p.SetValue(result, cell.GetValue()); + // break; + // case "double": + // p.SetValue(result, cell.GetValue()); break; + // case "datetime": + // p.SetValue(result, cell.GetValue()); break; + // case "boolean": + // p.SetValue(result, cell.GetValue()); break; + // case "char": + // p.SetValue(result, cell.GetValue()); break; + // default: + // break; + // } + // } + // catch (KeyNotFoundException ex) + // { + // Console.WriteLine("未找到该列将继续循环," + ex.Message); + // continue; + // } + // } + // resultList.Add(result); + // } - return resultList; - } + // return resultList; + //} /// /// 查找Excel列名对应的实体属性 diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj index 2cbb766..629c105 100644 --- a/ZR.Common/ZR.Common.csproj +++ b/ZR.Common/ZR.Common.csproj @@ -4,14 +4,14 @@ net7.0 - - - - - - - - + + + + + + + + diff --git a/ZR.Model/System/CommonLang.cs b/ZR.Model/System/CommonLang.cs index b48c740..84a0f91 100644 --- a/ZR.Model/System/CommonLang.cs +++ b/ZR.Model/System/CommonLang.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; -using SqlSugar; -using OfficeOpenXml.Attributes; using Newtonsoft.Json; +using SqlSugar; +using System; +using System.ComponentModel; namespace ZR.Model.Models { @@ -21,7 +20,6 @@ namespace ZR.Model.Models /// 空值 : false /// [JsonConverter(typeof(ValueToStringConverter))] - [EpplusTableColumn(Header = "id")] [SugarColumn(IsPrimaryKey = true)] public long Id { get; set; } @@ -29,7 +27,7 @@ namespace ZR.Model.Models /// 描述 : 语言code /// 空值 : false /// - [EpplusTableColumn(Header = "语言code")] + [DisplayName("语言code")] [SugarColumn(ColumnName = "lang_code")] public string LangCode { get; set; } @@ -37,7 +35,7 @@ namespace ZR.Model.Models /// 描述 : 语言key /// 空值 : true /// - [EpplusTableColumn(Header = "语言key")] + [DisplayName("语言key")] [SugarColumn(ColumnName = "lang_key")] public string LangKey { get; set; } @@ -45,7 +43,7 @@ namespace ZR.Model.Models /// 描述 : 名称 /// 空值 : false /// - [EpplusTableColumn(Header = "名称")] + [DisplayName("名称")] [SugarColumn(ColumnName = "lang_name")] public string LangName { get; set; } @@ -53,7 +51,7 @@ namespace ZR.Model.Models /// 描述 : 添加时间 /// 空值 : true /// - [EpplusTableColumn(Header = "添加时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] + [DisplayName("添加时间")] public DateTime? Addtime { get; set; } } } \ No newline at end of file diff --git a/ZR.Model/System/SysBase.cs b/ZR.Model/System/SysBase.cs index 7cb7a95..21ea490 100644 --- a/ZR.Model/System/SysBase.cs +++ b/ZR.Model/System/SysBase.cs @@ -1,60 +1,42 @@ -//using Dapper.Contrib.Extensions; +using MiniExcelLibs.Attributes; using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; using SqlSugar; -using OfficeOpenXml.Attributes; +using 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 { - [SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段 + [SugarColumn(IsOnlyIgnoreUpdate = true)] [JsonProperty(propertyName: "CreateBy")] - [EpplusIgnore] + [ExcelIgnore] public string Create_by { get; set; } - [SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段 + [SugarColumn(IsOnlyIgnoreUpdate = true)] [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; [JsonIgnore] [JsonProperty(propertyName: "UpdateBy")] [SugarColumn(IsOnlyIgnoreInsert = true)] - [EpplusIgnore] + [ExcelIgnore] public string Update_by { get; set; } //[JsonIgnore] - [SugarColumn(IsOnlyIgnoreInsert = true)]//设置后插入数据不会有此字段 + [SugarColumn(IsOnlyIgnoreInsert = true)] [JsonProperty(propertyName: "UpdateTime")] - [EpplusIgnore] + [ExcelIgnore] public DateTime? Update_time { get; set; } - public string Remark { get; set; } - - /// - /// 搜索时间起始时间 - /// - /// - /// Write:需穿一个bool值,false时insert,update等操作会忽略此列(和Computed的作用差不多,看了源码也没发现与Computed有什么不一样的地方,有了解的朋友可以赐教下哈) - /// ExplicitKey:指定此列为主键(不自动增长类型例如guid,ExplicitKey与Key地区别下面会详细讲) - /// Key:指定此列为主键(自动增长主键),可忽略,忽略后默认查找 - /// [Computed]计算属性,打上此标签,对象地insert,update等操作会忽略此列 - /// [SugarColumn(IsIgnore = true)] [JsonIgnore] - [EpplusIgnore] + [ExcelIgnore] public DateTime? BeginTime { get; set; } - - /// - /// 用于搜索使用 - /// [SugarColumn(IsIgnore = true)] [JsonIgnore] - [EpplusIgnore] + [ExcelIgnore] public DateTime? EndTime { get; set; } } } diff --git a/ZR.Model/System/SysDictType.cs b/ZR.Model/System/SysDictType.cs index 5e54970..17b07c1 100644 --- a/ZR.Model/System/SysDictType.cs +++ b/ZR.Model/System/SysDictType.cs @@ -1,5 +1,4 @@ -using OfficeOpenXml.Attributes; -using SqlSugar; +using SqlSugar; namespace ZR.Model.System { @@ -26,7 +25,6 @@ namespace ZR.Model.System /// /// 状态 0、正常 1、停用 /// - [EpplusIgnore] public string Status { get; set; } /// /// 系统内置 Y是 N否 diff --git a/ZR.Model/System/SysLogininfor.cs b/ZR.Model/System/SysLogininfor.cs index d470f97..9c0889e 100644 --- a/ZR.Model/System/SysLogininfor.cs +++ b/ZR.Model/System/SysLogininfor.cs @@ -1,5 +1,4 @@ -using OfficeOpenXml.Attributes; -using SqlSugar; +using SqlSugar; using System; namespace ZR.Model.System @@ -52,7 +51,6 @@ namespace ZR.Model.System /// /// 访问时间 /// - [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")] public DateTime LoginTime { get; set; } = DateTime.Now; [SugarColumn(IsIgnore = true)] public DateTime? BeginTime { get; set; } diff --git a/ZR.Model/System/SysOperLog.cs b/ZR.Model/System/SysOperLog.cs index 1a7c0d2..233ba26 100644 --- a/ZR.Model/System/SysOperLog.cs +++ b/ZR.Model/System/SysOperLog.cs @@ -1,6 +1,7 @@ -using OfficeOpenXml.Attributes; +using MiniExcelLibs.Attributes; using SqlSugar; using System; +using System.ComponentModel; namespace ZR.Model.System { @@ -11,78 +12,79 @@ namespace ZR.Model.System [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public long OperId { get; set; } /** 操作模块 */ - [EpplusTableColumn(Header = "操作模块")] + [DisplayName("操作模块")] public string Title { get; set; } /** 业务类型(0其它 1新增 2修改 3删除) */ //@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") - [EpplusTableColumn(Header = "业务类型")] + [DisplayName("业务类型")] public int BusinessType { get; set; } /** 业务类型数组 */ [SugarColumn(IsIgnore = true)] - [EpplusIgnore] + [ExcelIgnore] public int[] BusinessTypes { get; set; } /** 请求方法 */ - [EpplusTableColumn(Header = "请求方法")] + [DisplayName("请求方法")] public string Method { get; set; } /** 请求方式 */ - [EpplusTableColumn(Header = "请求方式")] + [DisplayName("请求方式")] public string RequestMethod { get; set; } /** 操作类别(0其它 1后台用户 2手机端用户) */ //@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") - [EpplusTableColumn(Header = "操作类别")] + [DisplayName("操作类别")] public int OperatorType { get; set; } /** 操作人员 */ - [EpplusTableColumn(Header = "操作人员")] + [DisplayName("操作人员")] public string OperName { get; set; } /** 部门名称 */ - [EpplusTableColumn(Header = "部门名称")] + [DisplayName("部门名称")] public string DeptName { get; set; } /** 请求url */ - [EpplusTableColumn(Header = "请求地址")] + [DisplayName("请求地址")] public string OperUrl { get; set; } /** 操作地址 */ - [EpplusTableColumn(Header = "操作地址")] + [DisplayName("操作地址")] public string OperIp { get; set; } /** 操作地点 */ - [EpplusTableColumn(Header = "操作地点")] + [DisplayName("操作地点")] public string OperLocation { get; set; } /** 请求参数 */ - [EpplusTableColumn(Header = "请求参数")] + [DisplayName("请求参数")] public string OperParam { get; set; } /** 返回参数 */ - [EpplusTableColumn(Header = "返回结果")] + [DisplayName("返回结果")] public string JsonResult { get; set; } /** 操作状态(0正常 1异常) */ - [EpplusTableColumn(Header = "状态")] + [DisplayName("状态")] public int Status { get; set; } /// /// 错误消息 /// - [EpplusTableColumn(Header = "错误消息")] + [DisplayName("错误消息")] public string ErrorMsg { get; set; } /// /// 操作时间 /// - [EpplusTableColumn(Header = "操作时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] + [DisplayName("操作时间")] public DateTime? OperTime { get; set; } /// /// 操作用时 /// + [DisplayName("操作用时")] public long Elapsed { get; set; } } } diff --git a/ZR.Model/System/SysPost.cs b/ZR.Model/System/SysPost.cs index 766cbc3..8441f26 100644 --- a/ZR.Model/System/SysPost.cs +++ b/ZR.Model/System/SysPost.cs @@ -1,5 +1,4 @@ -using OfficeOpenXml.Attributes; -using SqlSugar; +using SqlSugar; namespace ZR.Model.System { @@ -14,9 +13,7 @@ namespace ZR.Model.System public long PostId { get; set; } public string PostCode { get; set; } public string PostName { get; set; } - [EpplusIgnore] public int PostSort { get; set; } - [EpplusIgnore] public string Status { get; set; } } } diff --git a/ZR.Model/System/SysTasksLog.cs b/ZR.Model/System/SysTasksLog.cs index 8b03ec6..666f1ea 100644 --- a/ZR.Model/System/SysTasksLog.cs +++ b/ZR.Model/System/SysTasksLog.cs @@ -1,5 +1,4 @@ -using OfficeOpenXml.Attributes; -using SqlSugar; +using SqlSugar; using System; namespace ZR.Model.System @@ -39,7 +38,9 @@ namespace ZR.Model.System /// public string InvokeTarget { get; set; } - [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")] + /// + /// 创建时间 + /// public DateTime CreateTime { get; set; } /// /// 执行用时,毫秒 diff --git a/ZR.Model/System/SysUser.cs b/ZR.Model/System/SysUser.cs index 749a8dd..1520c28 100644 --- a/ZR.Model/System/SysUser.cs +++ b/ZR.Model/System/SysUser.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using OfficeOpenXml.Attributes; +using MiniExcelLibs.Attributes; +using Newtonsoft.Json; using SqlSugar; using System; using System.Collections.Generic; @@ -28,12 +28,12 @@ namespace ZR.Model.System //[JsonProperty(propertyName: "userType")] //public string User_type { get; set; } = ""; [SugarColumn(IsOnlyIgnoreInsert = true)] - [EpplusIgnore] + [ExcelIgnore] public string Avatar { get; set; } public string Email { get; set; } [JsonIgnore] - [EpplusIgnore] + [ExcelIgnore] public string Password { get; set; } /// /// 手机号 @@ -47,7 +47,7 @@ namespace ZR.Model.System /// /// 帐号状态(0正常 1停用) /// - [EpplusIgnore] + [ExcelIgnore] public string Status { get; set; } /// @@ -66,7 +66,7 @@ namespace ZR.Model.System /// 最后登录时间 /// [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; } /// @@ -95,17 +95,17 @@ namespace ZR.Model.System /// 角色id集合 /// [SugarColumn(IsIgnore = true)] - [EpplusIgnore] + [ExcelIgnore] public long[] RoleIds { get; set; } /// /// 岗位集合 /// [SugarColumn(IsIgnore = true)] - [EpplusIgnore] + [ExcelIgnore] public int[] PostIds { get; set; } [SugarColumn(IsIgnore = true)] - [EpplusIgnore] + [ExcelIgnore] public List Roles { get; set; } [SugarColumn(IsIgnore = true)] public string WelcomeMessage diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj index 937538a..7f9ffaa 100644 --- a/ZR.Model/ZR.Model.csproj +++ b/ZR.Model/ZR.Model.csproj @@ -5,7 +5,7 @@ - +