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; using GxPress.Repository.Interface.Media; namespace GxPress.Api.AppControllers { /// /// App首页数据 /// [Route("api/app/page")] [ApiController] [Authorize] public class AppPageController : Controller { private readonly IAppHomePageService appHomePageService; private readonly IMediaRepository mediaRepository; public AppPageController(IAppHomePageService appHomePageService, IMediaRepository mediaRepository) { this.appHomePageService = appHomePageService; this.mediaRepository = mediaRepository; } /// /// 大咖讲座 每日好书 /// /// /// [HttpPost("cathedra")] [AllowAnonymous] public async Task>> GetMediasByTeacherAsync(ArticleGroupRequest request) { if (string.IsNullOrEmpty(request.StyleCss)) throw new Common.Exceptions.BusinessException("样式未知!"); return await appHomePageService.GetMediasByTeacherAsync(request); } /// /// 大咖讲座分页接口 /// /// [HttpPost("cathedra-page")] [AllowAnonymous] public async Task> MediaCathedraResult(ArticleGroupRequest request) { return await appHomePageService.MediaCathedraResult(request); } /// /// 每日好文 /// /// /// [HttpPost("day-good-text")] [AllowAnonymous] public async Task> GetDayGoodTextAsync(MediaSearchRequest request) { request.MediaType = GxPress.EnumConst.AllTypeConst.Article.GetHashCode(); request.IsDelete = 0; request.IsChecked = 1; return await appHomePageService.GetDayGoodTextAsync(request); } /// /// 每日微课 /// /// /// [HttpPost("day-we-book")] [AllowAnonymous] public async Task> GetDayWeBookAsync(MediaSearchRequest request) { request.MediaType = GxPress.EnumConst.AllTypeConst.Curriculum.GetHashCode(); request.IsDelete = 0; request.IsChecked = 1; return await appHomePageService.GetDayGoodTextAsync(request); } /// /// 信源听说 /// /// /// [HttpPost("chat-hear-speak")] [AllowAnonymous] public async Task> GetChatHearSpeak(MediaSearchRequest request) { request.MediaType = GxPress.EnumConst.AllTypeConst.Audio.GetHashCode(); request.IsDelete = 0; request.IsChecked = 1; return await appHomePageService.GetDayGoodTextAsync(request); } /// /// 根据标签ID获取每日好书 分页换一批 /// /// [HttpPost("lable")] [AllowAnonymous] public async Task> GetMediaByLableIdsAsync(MediaIdsRequest request) { return await appHomePageService.GetMediaByLableIdsAsync(request); } /// /// 根据标签ID获取分页数据 /// /// [HttpPost("page-lable")] [AllowAnonymous] public async Task> GetMediaByLableIdAsync(MediaLableIdRequest request) { return await appHomePageService.GetMediaByLableIdAsync(request); } /// /// 名师 /// /// /// [HttpPost("teacher")] [AllowAnonymous] public async Task> GetTeacherAsync(TeacherRequest request) { return await appHomePageService.GetTeacherAsync(request); } /// /// 每日技能分页 /// /// [HttpPost("day-skill")] [AllowAnonymous] public async Task> GetDaySkillsAsync(Common.Page.PageParameter request) { return await mediaRepository.GetDaySkillsAsync(request); } /// /// 随机每日技能 /// /// [HttpGet("random-day-skill")] [AllowAnonymous] public async Task GetRandomDaySkillAsync() { return await mediaRepository.GetRandomDaySkillAsync(); } /// /// 书城 /// /// [HttpGet("book-city")] [AllowAnonymous] public async Task>> GetBookCityAsync() { ArticleGroupRequest request = new ArticleGroupRequest(); request.ActionUrl = "api/app/page/lable"; return await appHomePageService.GetBookCityAsync(request); } } }