TestPaperController.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using Exam.Application.Interface.Exam;
  2. using Exam.Application.Interface.TestPapers;
  3. using Exam.Infrastructure.Data.Entity;
  4. using Exam.Share.ViewResponses.Exam;
  5. using Exam.Share.ViewResponses.TestPaper;
  6. using Hotline.Application.Exam.Constants.ApiRoutes;
  7. using Hotline.Share.Dtos.TestPapers;
  8. using Hotline.Share.Requests.Exam;
  9. using Hotline.Share.ViewResponses.Exam;
  10. using Microsoft.AspNetCore.Mvc;
  11. namespace Hotline.Api.Controllers.Exam
  12. {
  13. public class TestPaperController : BaseController
  14. {
  15. private readonly ITestPaperService _testPaperService;
  16. public TestPaperController(ITestPaperService testPaperService)
  17. {
  18. _testPaperService = testPaperService;
  19. }
  20. /// <summary>
  21. /// 新增试卷
  22. /// </summary>
  23. /// <param name="extractRuleDto"></param>
  24. /// <returns></returns>
  25. [HttpPost(TestPaperApiRoute.Add)]
  26. public async Task Add([FromBody] AddTestPaperDto extractRuleDto)
  27. {
  28. await _testPaperService.AddAsync(extractRuleDto, HttpContext.RequestAborted);
  29. }
  30. /// <summary>
  31. /// 修改试卷
  32. /// </summary>
  33. /// <param name="extractRuleDto"></param>
  34. /// <returns></returns>
  35. [HttpPut(TestPaperApiRoute.Update)]
  36. public async Task Update([FromBody] UpdateTestPaperDto extractRuleDto)
  37. {
  38. await _testPaperService.UpdateAsync(extractRuleDto, HttpContext.RequestAborted);
  39. }
  40. /// <summary>
  41. /// 删除试卷
  42. /// </summary>
  43. /// <param name="entityQueryRequest"></param>
  44. /// <returns></returns>
  45. [HttpDelete(TestPaperApiRoute.Delete)]
  46. public async Task Delete(EntityQueryRequest entityQueryRequest)
  47. {
  48. await _testPaperService.DeleteAsync(entityQueryRequest, HttpContext.RequestAborted);
  49. }
  50. /// <summary>
  51. /// 获取课件分页列表
  52. /// </summary>
  53. /// <param name="sourcewarePagedRequest"></param>
  54. /// <returns></returns>
  55. [HttpPost(TestPaperApiRoute.GetPagedList)]
  56. public async Task<TestPaperPageViewResponse> GetPagedList([FromBody] TestPaperPagedRequest sourcewarePagedRequest)
  57. {
  58. var sourcewarePageViewResponse = await _testPaperService.GetPagedListAsync(sourcewarePagedRequest);
  59. return sourcewarePageViewResponse as TestPaperPageViewResponse;
  60. }
  61. /// <summary>
  62. /// 获取课件分类
  63. /// </summary>
  64. /// <param name="id"></param>
  65. /// <returns></returns>
  66. [HttpGet(TestPaperApiRoute.Get)]
  67. public async Task<TestPaperDto> Get(string id)
  68. {
  69. var extractRuleDto = await _testPaperService.GetAsync(new EntityQueryRequest
  70. {
  71. Id = id
  72. });
  73. return extractRuleDto;
  74. }
  75. /// <summary>
  76. /// 获取课件分页列表
  77. /// </summary>
  78. /// <returns></returns>
  79. [HttpGet(TestPaperApiRoute.Count)]
  80. public async Task<List<TestPaperQuestionCountViewResponse>> GetPagedList([FromQuery] TestPaperQuestionCountRequest testPaperQuestionCountRequest)
  81. {
  82. var testPaperQuestionCountViewResponses = await _testPaperService.GetTestPaperQuestionCount(testPaperQuestionCountRequest);
  83. return testPaperQuestionCountViewResponses;
  84. }
  85. }
  86. }