ExamTeacherAppService.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 监测教师管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-teacher")]
  7. [Route("exam/teacher")]
  8. public class ExamTeacherAppService : IDynamicApiController
  9. {
  10. private readonly IExamTeacherService _examTeacherService;
  11. public ExamTeacherAppService(IExamTeacherService examTeacherService)
  12. {
  13. _examTeacherService = examTeacherService;
  14. }
  15. #region 批量导入
  16. /// <summary>
  17. /// 上传监测教师批量导入文件
  18. /// </summary>
  19. /// <param name="input"></param>
  20. /// <returns></returns>
  21. [RequestSizeLimit(long.MaxValue)]
  22. [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
  23. public async Task<UploadExamDataOutput<UploadExamTeacherOutput>> Upload([FromForm] UploadExamDataInput input)
  24. {
  25. string fileExt = Path.GetExtension(input.File.FileName).ToLower();
  26. if (fileExt != ".xls" && fileExt != ".xlsx")
  27. {
  28. throw Oops.Oh(ErrorCode.E1010);
  29. }
  30. string filePath = Path.Combine(FileUtil.GetTempFileRoot(), $"{Guid.NewGuid()}{fileExt}");
  31. using FileStream fs = File.Create(filePath);
  32. await input.File.CopyToAsync(fs);
  33. await fs.FlushAsync();
  34. fs.Close();
  35. var ret = await _examTeacherService.Upload(filePath, input.ExamPlanId);
  36. return ret;
  37. }
  38. /// <summary>
  39. /// 批量导入监测教师
  40. /// </summary>
  41. /// <param name="input"></param>
  42. /// <returns></returns>
  43. public async Task Import(ImportExamTeacherInput input)
  44. {
  45. await _examTeacherService.Import(input);
  46. }
  47. #endregion
  48. #region 创建编辑
  49. /// <summary>
  50. /// 添加监测教师
  51. /// </summary>
  52. /// <param name="input"></param>
  53. /// <returns></returns>
  54. public async Task Add(AddExamTeacherInput input)
  55. {
  56. await _examTeacherService.Add(input);
  57. }
  58. /// <summary>
  59. /// 更新监测教师
  60. /// </summary>
  61. /// <param name="input"></param>
  62. /// <returns></returns>
  63. public async Task Update(UpdateExamTeacherInput input)
  64. {
  65. await _examTeacherService.Update(input);
  66. }
  67. /// <summary>
  68. /// 删除监测教师
  69. /// </summary>
  70. /// <param name="input"></param>
  71. /// <returns></returns>
  72. public async Task Del(BaseId input)
  73. {
  74. await _examTeacherService.Del(input);
  75. }
  76. /// <summary>
  77. /// 清空监测教师
  78. /// </summary>
  79. /// <param name="input"></param>
  80. /// <returns></returns>
  81. public async Task Clear(ClearExamTeacherInput input)
  82. {
  83. await _examTeacherService.Clear(input);
  84. }
  85. #endregion
  86. #region 查询统计
  87. /// <summary>
  88. /// 分页查询监测教师列表
  89. /// </summary>
  90. /// <param name="input"></param>
  91. /// <returns></returns>
  92. public async Task<PageResult<ExamTeacherOutput>> QueryPageList(ExamTeacherPageInput input)
  93. {
  94. return await _examTeacherService.QueryPageList(input);
  95. }
  96. #endregion
  97. }