123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 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
- {
- /// <summary>
- /// App首页数据
- /// </summary>
- [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;
- }
- /// <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("day-we-book")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetDayWeBookAsync(MediaSearchRequest request)
- {
- request.MediaType = GxPress.EnumConst.AllTypeConst.Curriculum.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<IEnumerable<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
- {
- return await appHomePageService.GetMediaByLableIdsAsync(request);
- }
- /// <summary>
- /// 根据标签ID获取分页数据
- /// </summary>
- /// <returns></returns>
- [HttpPost("page-lable")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdAsync(MediaLableIdRequest request)
- {
- return await appHomePageService.GetMediaByLableIdAsync(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);
- }
- /// <summary>
- /// 每日技能分页
- /// </summary>
- /// <returns></returns>
- [HttpPost("day-skill")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetDaySkillsAsync(Common.Page.PageParameter request)
- {
- return await mediaRepository.GetDaySkillsAsync(request);
- }
- /// <summary>
- /// 随机每日技能
- /// </summary>
- /// <returns></returns>
- [HttpGet("random-day-skill")]
- [AllowAnonymous]
- public async Task<SkillInfo> GetRandomDaySkillAsync()
- {
- return await mediaRepository.GetRandomDaySkillAsync();
- }
- /// <summary>
- /// 书城
- /// </summary>
- /// <returns></returns>
- [HttpGet("book-city")]
- [AllowAnonymous]
- public async Task<List<AppLabelResult<MediaCathedraResult>>> GetBookCityAsync()
- {
- ArticleGroupRequest request = new ArticleGroupRequest();
- request.ActionUrl = "api/app/page/lable";
- return await appHomePageService.GetBookCityAsync(request);
- }
- }
- }
|