字典表 加字段

Uat_Study
hang 2022-04-01 17:06:48 +08:00
parent aa18ce52f2
commit 555c9789b0
4 changed files with 53 additions and 31 deletions

View File

@ -2,6 +2,7 @@
using IRaCIS.Application.Services.BusinessFilter; using IRaCIS.Application.Services.BusinessFilter;
using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Infra.EFCore;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Panda.DynamicWebApi; using Panda.DynamicWebApi;
using Panda.DynamicWebApi.Attributes; using Panda.DynamicWebApi.Attributes;
@ -26,6 +27,8 @@ namespace IRaCIS.Core.Application
public IStringLocalizer _localizer { get; set; } public IStringLocalizer _localizer { get; set; }
public IWebHostEnvironment _hostEnvironment { get; set; }
@ -51,6 +54,9 @@ namespace IRaCIS.Core.Application
[MemberNotNull(nameof(_localizer))] [MemberNotNull(nameof(_localizer))]
public IStringLocalizer _localizer { get; set; } public IStringLocalizer _localizer { get; set; }
[MemberNotNull(nameof(_hostEnvironment))]
public IWebHostEnvironment _hostEnvironment { get; set; }
} }
#endregion #endregion

View File

@ -63,6 +63,9 @@ namespace IRaCIS.Application.Contracts
public string Value { get; set; } = string.Empty; public string Value { get; set; } = string.Empty;
public string Code { get; set; } = string.Empty; public string Code { get; set; } = string.Empty;
public string ChildGroup { get; set; } = string.Empty;
public int ShowOrder { get; set; } public int ShowOrder { get; set; }
public Guid? ParentId { get; set; } public Guid? ParentId { get; set; }

View File

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
using Magicodes.ExporterAndImporter.Core;
namespace IRaCIS.Application.Contracts namespace IRaCIS.Application.Contracts
{ {
@ -36,8 +37,11 @@ namespace IRaCIS.Application.Contracts
public class TrialMaintenanceDTO : UserTrialCommand public class TrialMaintenanceDTO : UserTrialCommand
{ {
[ValueMapping(text: "退出", true)]
[ValueMapping(text: "加入", false)]
public bool IsDeleted { get; set; } public bool IsDeleted { get; set; }
[ExporterHeader(Format = "yyyy-mm-dd hh:mm:ss")]
public DateTime? DeletedTime { get; set; } public DateTime? DeletedTime { get; set; }
public DateTime? RemoveTime { get; set; } public DateTime? RemoveTime { get; set; }
@ -45,6 +49,9 @@ namespace IRaCIS.Application.Contracts
public DateTime? JoinTime { get; set; } public DateTime? JoinTime { get; set; }
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
public string Phone { get; set; } = String.Empty;
public string EMail { get; set; } = string.Empty;
public DateTime UpdateTime { get; set; } = DateTime.Now; public DateTime UpdateTime { get; set; } = DateTime.Now;
@ -65,6 +72,7 @@ namespace IRaCIS.Application.Contracts
public class TrialUserExportDTO public class TrialUserExportDTO
{ {
public DateTime CurrentTime { get; set; } = DateTime.Now;
public TrialSelectDTO TrialInfo { get; set; } public TrialSelectDTO TrialInfo { get; set; }
public List<TrialMaintenanceDTO> TrialUserList { get; set; } = new List<TrialMaintenanceDTO>(); public List<TrialMaintenanceDTO> TrialUserList { get; set; } = new List<TrialMaintenanceDTO>();

View File

@ -8,6 +8,7 @@ using IRaCIS.Application.Interfaces;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Excel.AspNetCore; using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -46,44 +47,48 @@ namespace IRaCIS.Application.Services
} }
//[HttpGet] [HttpGet]
//public async Task<IActionResult> TrialUserListExport(Guid trialId) public async Task<IActionResult> TrialUserListExport(Guid trialId, [FromServices] IRepository<CommonDocument> _commonDocumentRepository)
//{ {
// var exportInfo = new TrialUserExportDTO() var doc = _commonDocumentRepository.AsQueryable(true).FirstOrDefault(t => t.Code == "Test");
// {
// TrialInfo = await _trialRepository.ProjectTo<TrialSelectDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync(),
// TrialUserList = await _trialUseRepository.Where(t => t.TrialId == trialId).IgnoreQueryFilters().ProjectTo<TrialMaintenanceDTO>(_mapper.ConfigurationProvider).ToListAsync()
// };
// IExporter exporter = new ExcelExporter(); if (doc == null)
{
throw new Exception("当前code 没要找到对应的文件");
}
// ////模板路径 var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
// //var tplPath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "ExportTemplates",
// // "2020年春季教材订购明细样表.xlsx");
// ////创建Excel导出对象
// //IExportFileByTemplate exporter = new ExcelExporter();
// ////导出路径
// //var filePath = Path.Combine(Directory.GetCurrentDirectory(), nameof(ExportByTemplate_Test) + ".xlsx");
// //if (File.Exists(filePath)) File.Delete(filePath);
// ////根据模板导出
// //await exporter.ExportByTemplate(filePath,
// // new TextbookOrderInfo("湖南心莱信息科技有限公司", "湖南长沙岳麓区", "雪雁", "1367197xxxx", "雪雁", DateTime.Now.ToLongDateString(),
// // new List<BookInfo>()
// // {
// // new BookInfo(1, "0000000001", "《XX从入门到放弃》", "张三", "机械工业出版社", "3.14", 100, "备注"),
// // new BookInfo(2, "0000000002", "《XX从入门到放弃》", "张三", "机械工业出版社", "3.14", 100, "备注"),
// // new BookInfo(3, "0000000003", "《XX从入门到放弃》", "张三", "机械工业出版社", "3.14", 100, "备注")
// // }),
// // tplPath);
// //var result = await exporter.ExportAsByteArray(list); var filePath = Path.Combine(rootPath, doc.Path.Trim('/'));
if (!System.IO.File.Exists(filePath))
{
throw new Exception("服务器本地不存在该路径文件");
}
// return new XlsxFileResult(bytes: result, fileDownloadName: $"检查导出_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"); var exportInfo = new TrialUserExportDTO()
{
TrialInfo = await _trialRepository.ProjectTo<TrialSelectDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync(),
TrialUserList = await _trialUseRepository.Where(t => t.TrialId == trialId).IgnoreQueryFilters().ProjectTo<TrialMaintenanceDTO>(_mapper.ConfigurationProvider).ToListAsync()
};
//} //模板路径
var tplPath = filePath;
//创建Excel导出对象
IExportFileByTemplate exporter = new ExcelExporter();
//根据模板导出
var result = await exporter.ExportBytesByTemplate(exportInfo, tplPath);
return new XlsxFileResult(bytes: result, fileDownloadName: $"{doc.Name}_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx");
}