123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- 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;
- using GxPress.EnumConst;
- using GxPress.Common.Tools;
- using GxPress.Result.Category;
- using GxPress.Repository.Interface.Category;
- using GxPress.Service.Interface.Media;
- using GxPress.Result.Navigation;
- using GxPress.Request.Navigation;
- using GxPress.Result.AppChannel;
- using GxPress.Service.Interface.AppChannel;
- using GxPress.Request.AppChannel;
- 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;
- private readonly IMediaService mediaService;
- private readonly ICategoryRepository categoryRepository;
- private readonly IAppChannelService appChannelService;
- public AppPageController(IAppHomePageService appHomePageService, IMediaRepository mediaRepository, ICategoryRepository categoryRepository, IMediaService mediaService, IAppChannelService appChannelService)
- {
- this.appHomePageService = appHomePageService;
- this.mediaRepository = mediaRepository;
- this.categoryRepository = categoryRepository;
- this.mediaService = mediaService;
- this.appChannelService = appChannelService;
- }
- /// <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>
- /// <returns></returns>
- [HttpPost("day-we-book")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetDayWeBookAsync(MediaDayWeBookRequest request)
- {
- request.Name = "每日微课";
- return await appHomePageService.GetDayWeBookAsync(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(MediaDayWeBookRequest request)
- {
- request.TypeValue = AllTypeConst.Article.GetHashCode();
- 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);
- }
- /// <summary>
- /// 猜你喜欢
- /// </summary>
- /// <returns></returns>
- [HttpGet("user-like")]
- [AllowAnonymous]
- public async Task<IEnumerable<MediaCathedraResult>> GetUserLikeAsync()
- {
- var result = await mediaRepository.GetUserLikeAsync();
- foreach (var item in result)
- {
- item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
- }
- return result;
- }
- /// <summary>
- /// 导航内容分页
- /// </summary>
- /// <returns></returns>
- [HttpPost("content-navigation-list")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetContentNavigationAsync(MediaContentNavigationRequest request)
- {
- if (request.MediaIds == null)
- request.MediaIds = new List<int>();
- return await appHomePageService.GetContentNavigationAsync(request);
- }
- /// <summary>
- /// 内容导航分类
- /// </summary>
- /// <returns></returns>
- [HttpGet("category")]
- [AllowAnonymous]
- public async Task<IEnumerable<CategoryResult>> GetCategoryAllAsync()
- {
- return await categoryRepository.GetCategoryAllAsync(1);
- }
- /// <summary>
- /// 榜单
- /// </summary>
- /// <returns></returns>
- [HttpGet("ranking")]
- [AllowAnonymous]
- public async Task<List<MediaRankingResult>> GetRankingListResults()
- {
- var dictionary = new Dictionary<int, string>() { { 2, "热书榜" }, { 3, "课程榜" }, { 4, "文献头条" }, { 6, "视听榜" } };
- var dictionaryMedia = new Dictionary<int, string>() {
- { AllTypeConst.Book.GetHashCode(), "热书榜" },
- { AllTypeConst.Curriculum.GetHashCode(), "课程榜" },
- { AllTypeConst.Article.GetHashCode(), "文献头条" },
- { AllTypeConst.Audio.GetHashCode(), "视听榜" } };
- var result = new List<MediaRankingResult>();
- foreach (var item in dictionary)
- {
- var mediaRankingResult = new MediaRankingResult();
- var request = new RankingListRequest();
- request.DataTypeValue = item.Key;
- mediaRankingResult.Name = item.Value;
- mediaRankingResult.Items = await mediaRepository.GetRankingListResults(request);
- foreach (var dic in dictionaryMedia)
- {
- if (dic.Value.Equals(item.Value))
- mediaRankingResult.MediaType = dic.Key;
- }
- result.Add(mediaRankingResult);
- }
- return result;
- }
- /// <summary>
- /// 排行榜分页 1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条 6试听榜 7大众热评 8Top 100 专著
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("ranking-page")]
- [AllowAnonymous]
- public async Task<PagedList<RankingListResult>> GetRankingPageListResults(RankingListRequest request)
- {
- return await mediaRepository.GetRankingPageListResults(request);
- }
- /// <summary>
- /// 明栏
- /// </summary>
- /// <returns></returns>
- [HttpGet("star")]
- [AllowAnonymous]
- public async Task<IEnumerable<MediaStarLableResult>> GetMediaStarLableResultAysnc()
- {
- return await mediaService.GetMediaStarLableResultAysnc();
- }
- /// <summary>
- /// 明栏分页
- /// </summary>
- /// <returns></returns>
- [HttpPost("star-page")]
- [AllowAnonymous]
- public async Task<PagedList<MediaCathedraResult>> GetStarLablePageAsync(MediaStarLableRequest request)
- {
- return await mediaService.GetStarLablePageAsync(request);
- }
- /// <summary>
- /// 获取搜索内容
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("navigation-search")]
- [AllowAnonymous]
- public async Task<NavigationSearchResult> GetNavigationSearchResultAsync(NavigationSearchRequest request)
- {
- return await appHomePageService.GetNavigationSearchResultAsync(request);
- }
- /// <summary>
- /// 获取App频道
- /// </summary>
- /// <returns></returns>
- [HttpGet("channel")]
- [AllowAnonymous]
- public async Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync()
- {
- return await appChannelService.GetAppChannelsAsync();
- }
- /// <summary>
- /// 查询 获取频道分类
- /// </summary>
- /// <returns></returns>
- [HttpGet("channel-category/{appChannelId}")]
- [AllowAnonymous]
- public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)
- {
- return await appChannelService.GetAllAsync(appChannelId);
- }
- /// <summary>
- /// 根据频道分类ID获取分页数据
- /// </summary>
- /// <returns></returns>
- [HttpPost("channel-category-media")]
- [AllowAnonymous]
- public async Task<PagedList<MediaChannelCategoryResult>> GetChannelCategoryMediaPageAsync(AppChannelSearchRequest request)
- {
- var result = new PagedList<MediaChannelCategoryResult>();
- if (request.CategoryId > 0)
- {
- if (await appChannelService.IsChildrenAsync(request.CategoryId))
- {
- var categroys = await appChannelService.GetAllByParentIdAsync(request);
- result.Total = categroys.Total;
- var list = new List<MediaChannelCategoryResult>();
- foreach (var item in categroys.Items)
- {
- list.Add(new MediaChannelCategoryResult { Id = item.Id, Name = item.Name, ExpandName = item.ExpandName, IsCategory = true });
- }
- result.Items = list;
- return result;
- }
- //return await appChannelService.GetChannelCategoryMediaPageAsync(request);
- }
- return await appChannelService.GetChannelCategoryMediaPageAsync(request);
- }
- /// <summary>
- /// 书籍SKU
- /// </summary>
- /// <returns></returns>
- [HttpGet("sku")]
- [AllowAnonymous]
- public async Task<SkuResult> SkuResultAsync()
- {
- return await appHomePageService.SkuResultAsync();
- }
- }
- }
|