BizCourseController.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.Options;
  5. using System.Text.Json;
  6. using System.Threading.Tasks;
  7. using TEAMModelOS.Filter;
  8. using TEAMModelOS.Models;
  9. using TEAMModelOS.SDK;
  10. using TEAMModelOS.SDK.DI;
  11. using TEAMModelOS.SDK.Extension;
  12. namespace TEAMModelOS.Controllers
  13. {
  14. [Route("business")]
  15. [ApiController]
  16. public class BizCourseController : ControllerBase
  17. {
  18. public AzureCosmosFactory _azureCosmos;
  19. private readonly AzureStorageFactory _azureStorage;
  20. private readonly AzureRedisFactory _azureRedis;
  21. private readonly DingDing _dingDing;
  22. private readonly Option _option;
  23. private readonly IConfiguration _configuration;
  24. private readonly CoreAPIHttpService _coreAPIHttpService;
  25. private readonly AzureServiceBusFactory _serviceBus;
  26. public BizCourseController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, AzureServiceBusFactory serviceBus)
  27. {
  28. _azureCosmos = azureCosmos;
  29. _azureStorage = azureStorage;
  30. _azureRedis = azureRedis;
  31. _dingDing = dingDing;
  32. _option = option?.Value;
  33. _configuration = configuration;
  34. _coreAPIHttpService = coreAPIHttpService;
  35. _serviceBus = serviceBus;
  36. }
  37. /// <summary>
  38. /// 学校获取课程列表信息
  39. /// </summary>
  40. /// <param name="json"></param>
  41. /// <returns></returns>
  42. [ProducesDefaultResponseType]
  43. [HttpPost("get-course-list")]
  44. [ApiToken(Auth = "1301", Name = "获取课程列表信息",TName = "取得課程清單", EName = "Obtain course list information", RWN = "R", Limit = false)]
  45. public async Task<IActionResult> GetCourseList(JsonElement json)
  46. {
  47. var (id, school) = HttpContext.GetApiTokenInfo();
  48. var responseData = await OpenApiService.GetCourseList(_azureCosmos, _dingDing, id, school, json);
  49. return Ok(new { responseData });
  50. }
  51. /// <summary>
  52. /// 学校课程详细信息
  53. /// </summary>
  54. /// <param name="json"></param>
  55. /// <returns></returns>
  56. [ProducesDefaultResponseType]
  57. [HttpPost("get-course-info")]
  58. [ApiToken(Auth = "1302", Name = "课程详细信息",TName = "取得課程詳細資訊", EName = "Course Detail Information", RWN = "R", Limit = false)]
  59. public async Task<IActionResult> GetCourseInfo(JsonElement json)
  60. {
  61. var (id, school) = HttpContext.GetApiTokenInfo();
  62. var responseData = await OpenApiService.GetCourseInfo(_azureCosmos, _dingDing, id, school, json);
  63. return Ok(new { responseData });
  64. }
  65. /// <summary>
  66. /// 获取指定学段作息
  67. /// </summary>
  68. /// <param name="request"></param>
  69. /// <returns></returns>
  70. [ProducesDefaultResponseType]
  71. [HttpPost("get-period-info")]
  72. [ApiToken(Auth = "1303", Name = "获取指定学段信息",TName = "取得指定學制資訊", EName = "Obtain specified school year information", RWN = "R", Limit = false)]
  73. public async Task<IActionResult> GetPaperExamCondition(JsonElement json)
  74. {
  75. var (id, school) = HttpContext.GetApiTokenInfo();
  76. var responseData = await OpenApiService.GetPaperExamCondition(_azureCosmos, _dingDing, id, school, json);
  77. return Ok(new { responseData });
  78. }
  79. }
  80. }