ExamStudentAppService.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 监测学生管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-student")]
  7. [Route("exam/student")]
  8. public class ExamStudentAppService : IDynamicApiController
  9. {
  10. private readonly IExamStudentService _examStudentService;
  11. public ExamStudentAppService(IExamStudentService examStudentService)
  12. {
  13. _examStudentService = examStudentService;
  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<UploadExamStudentOutput>> Upload([FromForm] UploadExamStudentInput 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 _examStudentService.Upload(filePath, input.ExamPlanId, input.ExamGradeId);
  36. return ret;
  37. }
  38. /// <summary>
  39. /// 批量导入监测学生
  40. /// </summary>
  41. /// <param name="input"></param>
  42. /// <returns></returns>
  43. public async Task Import(ImportExamStudentInput input)
  44. {
  45. await _examStudentService.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(AddExamStudentInput input)
  55. {
  56. await _examStudentService.Add(input);
  57. }
  58. /// <summary>
  59. /// 更新监测学生
  60. /// </summary>
  61. /// <param name="input"></param>
  62. /// <returns></returns>
  63. public async Task Update(UpdateExamStudentInput input)
  64. {
  65. await _examStudentService.Update(input);
  66. }
  67. /// <summary>
  68. /// 删除监测学生
  69. /// </summary>
  70. /// <param name="input"></param>
  71. /// <returns></returns>
  72. public async Task Del(BaseId<long> input)
  73. {
  74. await _examStudentService.Del(input);
  75. }
  76. /// <summary>
  77. /// 清空监测学生
  78. /// </summary>
  79. /// <param name="input"></param>
  80. /// <returns></returns>
  81. public async Task Clear(ClearExamStudentInput input)
  82. {
  83. await _examStudentService.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<ExamStudentOutput>> QueryPageList(ExamStudentPageInput input)
  93. {
  94. return await _examStudentService.QueryPageList(input);
  95. }
  96. /// <summary>
  97. /// 获取机构班级上报人数统计列表
  98. /// </summary>
  99. /// <param name="examPlanId"></param>
  100. /// <returns></returns>
  101. public async Task<ExamStudentGradeClassStudentCountOutput> GetOrgGradeClassStudentCount([FromQuery][Required] int examPlanId)
  102. {
  103. return await _examStudentService.GetOrgGradeClassStudentCount(examPlanId);
  104. }
  105. /// <summary>
  106. /// 分页查询班级学生人数
  107. /// </summary>
  108. /// <param name="input"></param>
  109. /// <returns></returns>
  110. public async Task<PageResult<ExamStudentCountItem>> QueryStudentCountPageList(ExamStudentCountPageInput input)
  111. {
  112. return await _examStudentService.QueryStudentCountPageList(input);
  113. }
  114. #endregion
  115. }