AppPageController.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Common.Page;
  4. using GxPress.Request.ArticleGroup;
  5. using GxPress.Request.Media;
  6. using GxPress.Request.TeacherRequest;
  7. using GxPress.Result.Media;
  8. using GxPress.Result.SystemLabel;
  9. using GxPress.Result.Teacher;
  10. using GxPress.Service.Interface.AppHomePage;
  11. using Microsoft.AspNetCore.Authorization;
  12. using Microsoft.AspNetCore.Mvc;
  13. using GxPress.Repository.Interface.Media;
  14. namespace GxPress.Api.AppControllers
  15. {
  16. /// <summary>
  17. /// App首页数据
  18. /// </summary>
  19. [Route("api/app/page")]
  20. [ApiController]
  21. [Authorize]
  22. public class AppPageController : Controller
  23. {
  24. private readonly IAppHomePageService appHomePageService;
  25. private readonly IMediaRepository mediaRepository;
  26. public AppPageController(IAppHomePageService appHomePageService, IMediaRepository mediaRepository)
  27. {
  28. this.appHomePageService = appHomePageService;
  29. this.mediaRepository = mediaRepository;
  30. }
  31. /// <summary>
  32. /// 大咖讲座 每日好书
  33. /// </summary>
  34. /// <param name="request"></param>
  35. /// <returns></returns>
  36. [HttpPost("cathedra")]
  37. [AllowAnonymous]
  38. public async Task<List<AppLabelResult<MediaCathedraResult>>> GetMediasByTeacherAsync(ArticleGroupRequest request)
  39. {
  40. if (string.IsNullOrEmpty(request.StyleCss))
  41. throw new Common.Exceptions.BusinessException("样式未知!");
  42. return await appHomePageService.GetMediasByTeacherAsync(request);
  43. }
  44. /// <summary>
  45. /// 大咖讲座分页接口
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpPost("cathedra-page")]
  49. [AllowAnonymous]
  50. public async Task<PagedList<MediaCathedraResult>> MediaCathedraResult(ArticleGroupRequest request)
  51. {
  52. return await appHomePageService.MediaCathedraResult(request);
  53. }
  54. /// <summary>
  55. /// 每日好文
  56. /// </summary>
  57. /// <param name="request"></param>
  58. /// <returns></returns>
  59. [HttpPost("day-good-text")]
  60. [AllowAnonymous]
  61. public async Task<PagedList<MediaCathedraResult>> GetDayGoodTextAsync(MediaSearchRequest request)
  62. {
  63. request.MediaType = GxPress.EnumConst.AllTypeConst.Article.GetHashCode();
  64. request.IsDelete = 0;
  65. request.IsChecked = 1;
  66. return await appHomePageService.GetDayGoodTextAsync(request);
  67. }
  68. /// <summary>
  69. /// 每日微课
  70. /// </summary>
  71. /// <param name="request"></param>
  72. /// <returns></returns>
  73. [HttpPost("day-we-book")]
  74. [AllowAnonymous]
  75. public async Task<PagedList<MediaCathedraResult>> GetDayWeBookAsync(MediaSearchRequest request)
  76. {
  77. request.MediaType = GxPress.EnumConst.AllTypeConst.Curriculum.GetHashCode();
  78. request.IsDelete = 0;
  79. request.IsChecked = 1;
  80. return await appHomePageService.GetDayGoodTextAsync(request);
  81. }
  82. /// <summary>
  83. /// 信源听说
  84. /// </summary>
  85. /// <param name="request"></param>
  86. /// <returns></returns>
  87. [HttpPost("chat-hear-speak")]
  88. [AllowAnonymous]
  89. public async Task<PagedList<MediaCathedraResult>> GetChatHearSpeak(MediaSearchRequest request)
  90. {
  91. request.MediaType = GxPress.EnumConst.AllTypeConst.Audio.GetHashCode();
  92. request.IsDelete = 0;
  93. request.IsChecked = 1;
  94. return await appHomePageService.GetDayGoodTextAsync(request);
  95. }
  96. /// <summary>
  97. /// 根据标签ID获取每日好书 分页换一批
  98. /// </summary>
  99. /// <returns></returns>
  100. [HttpPost("lable")]
  101. [AllowAnonymous]
  102. public async Task<IEnumerable<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
  103. {
  104. return await appHomePageService.GetMediaByLableIdsAsync(request);
  105. }
  106. /// <summary>
  107. /// 根据标签ID获取分页数据
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost("page-lable")]
  111. [AllowAnonymous]
  112. public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdAsync(MediaLableIdRequest request)
  113. {
  114. return await appHomePageService.GetMediaByLableIdAsync(request);
  115. }
  116. /// <summary>
  117. /// 名师
  118. /// </summary>
  119. /// <param name="request"></param>
  120. /// <returns></returns>
  121. [HttpPost("teacher")]
  122. [AllowAnonymous]
  123. public async Task<PagedList<TeacherResult>> GetTeacherAsync(TeacherRequest request)
  124. {
  125. return await appHomePageService.GetTeacherAsync(request);
  126. }
  127. /// <summary>
  128. /// 每日技能分页
  129. /// </summary>
  130. /// <returns></returns>
  131. [HttpPost("day-skill")]
  132. [AllowAnonymous]
  133. public async Task<PagedList<MediaCathedraResult>> GetDaySkillsAsync(Common.Page.PageParameter request)
  134. {
  135. return await mediaRepository.GetDaySkillsAsync(request);
  136. }
  137. /// <summary>
  138. /// 随机每日技能
  139. /// </summary>
  140. /// <returns></returns>
  141. [HttpGet("random-day-skill")]
  142. [AllowAnonymous]
  143. public async Task<SkillInfo> GetRandomDaySkillAsync()
  144. {
  145. return await mediaRepository.GetRandomDaySkillAsync();
  146. }
  147. /// <summary>
  148. /// 书城
  149. /// </summary>
  150. /// <returns></returns>
  151. [HttpGet("book-city")]
  152. [AllowAnonymous]
  153. public async Task<List<AppLabelResult<MediaCathedraResult>>> GetBookCityAsync()
  154. {
  155. ArticleGroupRequest request = new ArticleGroupRequest();
  156. request.ActionUrl = "api/app/page/lable";
  157. return await appHomePageService.GetBookCityAsync(request);
  158. }
  159. }
  160. }