EPPlus替换成miniExcel
This commit is contained in:
parent
d32c211aee
commit
1792bb773d
@ -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
|
||||
/// <summary>
|
||||
/// 导出Excel
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="path">完整文件路径</param>
|
||||
/// <param name="fileName">带扩展文件名</param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <param name="fileName"></param>
|
||||
protected string ExportExcel<T>(List<T> list, string sheetName, string fileName)
|
||||
{
|
||||
var fileInfo = ExportExcelNew(list, sheetName, fileName);
|
||||
|
||||
return fileInfo.Item1;
|
||||
return ExportExcelMini(list, sheetName, fileName).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));
|
||||
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);
|
||||
|
||||
return (sFileName, newFileName);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
|
||||
|
||||
MiniExcel.SaveAs(fullPath, list, sheetName: sheetName);
|
||||
return (sFileName, fullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<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
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
<PackageReference Include="NLog" Version="5.0.4" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.1.4" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="EPPlus" Version="6.0.5" />
|
||||
<PackageReference Include="Hei.Captcha" Version="0.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<T> where T : new()
|
||||
@ -13,84 +13,84 @@ namespace ZR.Common
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> ImportData(Stream stream)
|
||||
{
|
||||
using ExcelPackage package = new(stream);
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet
|
||||
//获取表格的列数和行数
|
||||
//public static IEnumerable<T> 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<T> resultList = new();
|
||||
List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
|
||||
Dictionary<string, int> dictHeader = new();
|
||||
for (int i = colStart; i < colEnd; i++)
|
||||
{
|
||||
var name = worksheet.Cells[rowStart, i].Value.ToString();
|
||||
dictHeader[name] = i;
|
||||
// List<T> resultList = new();
|
||||
// List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
|
||||
// Dictionary<string, int> 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<string>());
|
||||
break;
|
||||
case "int16":
|
||||
p.SetValue(result, cell.GetValue<short>()); break;
|
||||
case "int32":
|
||||
p.SetValue(result, cell.GetValue<int>()); break;
|
||||
case "int64":
|
||||
p.SetValue(result, cell.GetValue<long>()); break;
|
||||
case "decimal":
|
||||
p.SetValue(result, cell.GetValue<decimal>());
|
||||
break;
|
||||
case "double":
|
||||
p.SetValue(result, cell.GetValue<double>()); break;
|
||||
case "datetime":
|
||||
p.SetValue(result, cell.GetValue<DateTime>()); break;
|
||||
case "boolean":
|
||||
p.SetValue(result, cell.GetValue<bool>()); break;
|
||||
case "char":
|
||||
p.SetValue(result, cell.GetValue<string>()); 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<string>());
|
||||
// break;
|
||||
// case "int16":
|
||||
// p.SetValue(result, cell.GetValue<short>()); break;
|
||||
// case "int32":
|
||||
// p.SetValue(result, cell.GetValue<int>()); break;
|
||||
// case "int64":
|
||||
// p.SetValue(result, cell.GetValue<long>()); break;
|
||||
// case "decimal":
|
||||
// p.SetValue(result, cell.GetValue<decimal>());
|
||||
// break;
|
||||
// case "double":
|
||||
// p.SetValue(result, cell.GetValue<double>()); break;
|
||||
// case "datetime":
|
||||
// p.SetValue(result, cell.GetValue<DateTime>()); break;
|
||||
// case "boolean":
|
||||
// p.SetValue(result, cell.GetValue<bool>()); break;
|
||||
// case "char":
|
||||
// p.SetValue(result, cell.GetValue<string>()); break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// catch (KeyNotFoundException ex)
|
||||
// {
|
||||
// Console.WriteLine("未找到该列将继续循环," + ex.Message);
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// resultList.Add(result);
|
||||
// }
|
||||
|
||||
return resultList;
|
||||
}
|
||||
// return resultList;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 查找Excel列名对应的实体属性
|
||||
|
||||
@ -4,14 +4,14 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.3" />
|
||||
<PackageReference Include="EPPlus" Version="6.0.5" />
|
||||
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.2" />
|
||||
<PackageReference Include="MailKit" Version="3.4.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.669" />
|
||||
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.2" />
|
||||
<PackageReference Include="MailKit" Version="3.4.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
||||
<PackageReference Include="MiniExcel" Version="1.29.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
|
||||
@ -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
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "id")]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
@ -29,7 +27,7 @@ namespace ZR.Model.Models
|
||||
/// 描述 : 语言code
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "语言code")]
|
||||
[DisplayName("语言code")]
|
||||
[SugarColumn(ColumnName = "lang_code")]
|
||||
public string LangCode { get; set; }
|
||||
|
||||
@ -37,7 +35,7 @@ namespace ZR.Model.Models
|
||||
/// 描述 : 语言key
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "语言key")]
|
||||
[DisplayName("语言key")]
|
||||
[SugarColumn(ColumnName = "lang_key")]
|
||||
public string LangKey { get; set; }
|
||||
|
||||
@ -45,7 +43,7 @@ namespace ZR.Model.Models
|
||||
/// 描述 : 名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "名称")]
|
||||
[DisplayName("名称")]
|
||||
[SugarColumn(ColumnName = "lang_name")]
|
||||
public string LangName { get; set; }
|
||||
|
||||
@ -53,7 +51,7 @@ namespace ZR.Model.Models
|
||||
/// 描述 : 添加时间
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "添加时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
[DisplayName("添加时间")]
|
||||
public DateTime? Addtime { get; set; }
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// 搜索时间起始时间
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Write:需穿一个bool值,false时insert,update等操作会忽略此列(和Computed的作用差不多,看了源码也没发现与Computed有什么不一样的地方,有了解的朋友可以赐教下哈)
|
||||
/// ExplicitKey:指定此列为主键(不自动增长类型例如guid,ExplicitKey与Key地区别下面会详细讲)
|
||||
/// Key:指定此列为主键(自动增长主键),可忽略,忽略后默认查找
|
||||
/// [Computed]计算属性,打上此标签,对象地insert,update等操作会忽略此列
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[JsonIgnore]
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public DateTime? BeginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用于搜索使用
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[JsonIgnore]
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
@ -26,7 +25,6 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 状态 0、正常 1、停用
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 系统内置 Y是 N否
|
||||
|
||||
@ -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
|
||||
/// <summary>
|
||||
/// 访问时间
|
||||
/// </summary>
|
||||
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
public DateTime LoginTime { get; set; } = DateTime.Now;
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public DateTime? BeginTime { get; set; }
|
||||
|
||||
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "错误消息")]
|
||||
[DisplayName("错误消息")]
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "操作时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
[DisplayName("操作时间")]
|
||||
public DateTime? OperTime { get; set; }
|
||||
/// <summary>
|
||||
/// 操作用时
|
||||
/// </summary>
|
||||
[DisplayName("操作用时")]
|
||||
public long Elapsed { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
/// </summary>
|
||||
public string InvokeTarget { get; set; }
|
||||
|
||||
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 执行用时,毫秒
|
||||
|
||||
@ -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; }
|
||||
/// <summary>
|
||||
/// 手机号
|
||||
@ -47,7 +47,7 @@ namespace ZR.Model.System
|
||||
/// <summary>
|
||||
/// 帐号状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -66,7 +66,7 @@ namespace ZR.Model.System
|
||||
/// 最后登录时间
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
||||
/// <summary>
|
||||
@ -95,17 +95,17 @@ namespace ZR.Model.System
|
||||
/// 角色id集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public long[] RoleIds { get; set; }
|
||||
/// <summary>
|
||||
/// 岗位集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public int[] PostIds { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[EpplusIgnore]
|
||||
[ExcelIgnore]
|
||||
public List<SysRole> Roles { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string WelcomeMessage
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<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="SqlSugarCoreNoDrive" Version="5.1.3.33" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user