平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.4 KiB

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