平安校园
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

IImportExportService.cs 2.4 KiB

4 месяцев назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 
  2. //
  3. namespace SafeCampus.System;
  4. /// <summary>
  5. /// 导入服务
  6. /// </summary>
  7. public interface IImportExportService : ITransient
  8. {
  9. /// <summary>
  10. /// 导出数据
  11. /// </summary>
  12. /// <typeparam name="T"></typeparam>
  13. /// <param name="data">数据</param>
  14. /// <param name="fileName">文件名</param>
  15. /// <returns>文件流</returns>
  16. Task<FileStreamResult> Export<T>(List<T> data, string fileName) where T : class, new();
  17. /// <summary>
  18. /// 获取本地模板
  19. /// </summary>
  20. /// <param name="fileName">文件名</param>
  21. /// <param name="templateFolder">模板文件夹路径:默认wwwroot下的Template</param>
  22. /// <returns>文件流</returns>
  23. FileStreamResult GenerateLocalTemplate(string fileName, string templateFolder = "Template");
  24. /// <summary>
  25. /// 生成模板
  26. /// </summary>
  27. /// <typeparam name="T">实体类</typeparam>
  28. /// <param name="fileName">文件名</param>
  29. /// <returns>文件流</returns>
  30. Task<FileStreamResult> GenerateTemplate<T>(string fileName) where T : class, new();
  31. /// <summary>
  32. /// 获取导入预览
  33. /// </summary>
  34. /// <typeparam name="T"></typeparam>
  35. /// <param name="file">文件</param>
  36. /// <returns>导入预览结果</returns>
  37. Task<ImportPreviewOutput<T>> GetImportPreview<T>(IFormFile file) where T : ImportTemplateInput, new();
  38. /// <summary>
  39. /// 获取预计导入结果
  40. /// </summary>
  41. /// <typeparam name="T"></typeparam>
  42. /// <param name="data">数据</param>
  43. /// <param name="importData">成功导入数据</param>
  44. /// <returns>预计导入结果</returns>
  45. ImportResultOutPut<T> GetImportResultPreview<T>(List<T> data, out List<T> importData) where T : ImportTemplateInput;
  46. /// <summary>
  47. /// 导入文件验证
  48. /// </summary>
  49. /// <param name="file">文件</param>
  50. /// <param name="maxSize">文件最大体积(M)</param>
  51. /// <param name="allowTypes">允许的格式</param>
  52. void ImportVerification(IFormFile file, int maxSize = 30, string[] allowTypes = null);
  53. /// <summary>
  54. /// 模板数据验证
  55. /// </summary>
  56. /// <typeparam name="T">模板类实体</typeparam>
  57. /// <param name="importResult">结果</param>
  58. /// <returns>导入预览数据</returns>
  59. ImportPreviewOutput<T> TemplateDataVerification<T>(ImportResult<T> importResult) where T : ImportTemplateInput;
  60. }