using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Common.Page; using GxPress.Request.ArticleGroup; using GxPress.Request.Media; using GxPress.Request.TeacherRequest; using GxPress.Result.Media; using GxPress.Result.SystemLabel; using GxPress.Result.Teacher; using GxPress.Service.Interface.AppHomePage; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AppControllers { /// <summary> /// App首页数据 /// </summary> [Route("api/app/page")] [ApiController] [Authorize] public class AppPageController : Controller { private readonly IAppHomePageService appHomePageService; public AppPageController(IAppHomePageService appHomePageService) { this.appHomePageService = appHomePageService; } /// <summary> /// 大咖讲座 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("cathedra")] [AllowAnonymous] public async Task<List<AppLabelResult<MediaCathedraResult>>> GetMediasByTeacherAsync(ArticleGroupRequest request) { if (string.IsNullOrEmpty(request.StyleCss)) throw new Common.Exceptions.BusinessException("样式未知!"); return await appHomePageService.GetMediasByTeacherAsync(request); } /// <summary> /// 大咖讲座分页接口 /// </summary> /// <returns></returns> [HttpPost("cathedra-page")] [AllowAnonymous] public async Task<PagedList<MediaCathedraResult>> MediaCathedraResult(ArticleGroupRequest request) { return await appHomePageService.MediaCathedraResult(request); } /// <summary> /// 每日好文 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("day-good-text")] [AllowAnonymous] public async Task<PagedList<MediaCathedraResult>> GetDayGoodTextAsync(MediaSearchRequest request) { request.MediaType = GxPress.EnumConst.AllTypeConst.Article.GetHashCode(); request.IsDelete = 0; request.IsChecked = 1; return await appHomePageService.GetDayGoodTextAsync(request); } /// <summary> /// 信源听说 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("chat-hear-speak")] [AllowAnonymous] public async Task<PagedList<MediaCathedraResult>> GetChatHearSpeak(MediaSearchRequest request) { request.MediaType = GxPress.EnumConst.AllTypeConst.Audio.GetHashCode(); request.IsDelete = 0; request.IsChecked = 1; return await appHomePageService.GetDayGoodTextAsync(request); } /// <summary> /// 根据标签ID获取每日好书 /// </summary> /// <returns></returns> [HttpPost("lable")] [AllowAnonymous] public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request) { return await appHomePageService.GetMediaByLableIdsAsync(request); } /// <summary> /// 名师 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("teacher")] [AllowAnonymous] public async Task<PagedList<TeacherResult>> GetTeacherAsync(TeacherRequest request) { return await appHomePageService.GetTeacherAsync(request); } } }