ExamTeacherCourseAppService.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 监测教师任教科目管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-teacher-course")]
  7. [Route("exam/teacher/course")]
  8. public class ExamTeacherCourseAppService:IDynamicApiController
  9. {
  10. private readonly IExamTeacherCourseService _examTeacherCourseService;
  11. public ExamTeacherCourseAppService(IExamTeacherCourseService examTeacherCourseService)
  12. {
  13. _examTeacherCourseService = examTeacherCourseService;
  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<UploadExamTeacherCourseOutput>> 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 _examTeacherCourseService.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(ImportExamTeacherCourseInput input)
  44. {
  45. await _examTeacherCourseService.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(AddExamTeacherCourseInput input)
  55. {
  56. await _examTeacherCourseService.Add(input);
  57. }
  58. /// <summary>
  59. /// 更新监测教师
  60. /// </summary>
  61. /// <param name="input"></param>
  62. /// <returns></returns>
  63. public async Task Update(UpdateExamTeacherCourseInput input)
  64. {
  65. await _examTeacherCourseService.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 _examTeacherCourseService.Del(input);
  75. }
  76. /// <summary>
  77. /// 清空监测教师
  78. /// </summary>
  79. /// <param name="input"></param>
  80. /// <returns></returns>
  81. public async Task Clear(ClearExamTeacherCourseInput input)
  82. {
  83. await _examTeacherCourseService.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<ExamTeacherCourseOutput>> QueryPageList(ExamTeacherCoursePageInput input)
  93. {
  94. return await _examTeacherCourseService.QueryPageList(input);
  95. }
  96. #endregion
  97. }