李昊 4 년 전
부모
커밋
78e8b94796

+ 37 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/AppPageController.cs

@@ -203,5 +203,42 @@ namespace GxPress.Api.AppControllers
         {
             return await categoryRepository.GetCategoryAllAsync(1);
         }
+        /// <summary>
+        /// 榜单
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpGet("ranking")]
+        [AllowAnonymous]
+        public async Task<List<MediaRankingResult>> GetRankingListResults()
+        {
+            var dictionary = new Dictionary<int, string>();
+            dictionary.Add(2, "热书榜");
+            dictionary.Add(3, "课程榜");
+            dictionary.Add(4, "文献头条");
+            dictionary.Add(6, "试听榜");
+            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.RankingListResults = await mediaRepository.GetRankingListResults(request);
+                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);
+        }
     }
 }

+ 36 - 0
gx_api/GxPress/Model/GxPress.Result/Media/MediaResult.cs

@@ -112,6 +112,21 @@ namespace GxPress.Result.Media
         /// 评分
         /// </summary>
         public decimal CommentScore { get; set; }
+        /// <summary>
+        /// 阅读量
+        /// </summary>
+        /// <value></value>
+        public int ReadCount { get; set; }
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        /// <value></value>
+        public DateTime? CreatedDate { get; set; }
+        /// <summary>
+        /// 时长
+        /// </summary>
+        /// <value></value>
+        public string Duration { get; set; }
     }
 
     public class RankingListCategoryResult
@@ -549,4 +564,25 @@ namespace GxPress.Result.Media
         /// <value></value>
         public int MediaType { get; set; }
     }
+    /// <summary>
+    /// 榜单
+    /// </summary>
+    public class MediaRankingResult
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public string Name { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int MediaType { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public IEnumerable<RankingListResult> RankingListResults { get; set; }
+    }
 }

+ 73 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -536,6 +536,8 @@ namespace GxPress.Repository.Implement.Media
             query.Select(nameof(Entity.tede2.Media.Media.MediaType));
             query.Select(nameof(Entity.tede2.Media.Media.Summary));
             query.Select(nameof(Entity.tede2.Media.Media.CommentScore));
+            query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
+            query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
             //1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条  6试听榜 7大众热评 8Top 100 专著
             if (request.DataTypeValue > 0)
             {
@@ -584,6 +586,77 @@ namespace GxPress.Repository.Implement.Media
             return await _repository.GetAllAsync<RankingListResult>(query);
         }
         /// <summary>
+        /// 排行榜分页
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<PagedList<RankingListResult>> GetRankingPageListResults(RankingListRequest request)
+        {
+            var result = new PagedList<RankingListResult>();
+            //获取媒体
+            var query = Q.NewQuery();
+            query.Select(nameof(Entity.tede2.Media.Media.Id));
+            query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
+            query.Select(nameof(Entity.tede2.Media.Media.Title));
+            query.Select(nameof(Entity.tede2.Media.Media.Summary));
+            query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
+            query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
+            query.Select(nameof(Entity.tede2.Media.Media.Author));
+            query.Select(nameof(Entity.tede2.Media.Media.MediaType));
+            query.Select(nameof(Entity.tede2.Media.Media.Summary));
+            query.Select(nameof(Entity.tede2.Media.Media.CommentScore));
+            query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
+            query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
+            //1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条  6试听榜 7大众热评 8Top 100 专著
+            if (request.DataTypeValue > 0)
+            {
+                //1 热搜
+                if (request.DataTypeValue == RankingListConst.HotSearch.GetHashCode())
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                //2热书榜
+                if (request.DataTypeValue == RankingListConst.ReadBook.GetHashCode())
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                //3 课程榜
+                if (request.DataTypeValue == RankingListConst.Article.GetHashCode())
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                //Top 100 新书
+                if (request.DataTypeValue == RankingListConst.NewBook.GetHashCode())
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
+                }
+                //文献头条
+                if (request.DataTypeValue == RankingListConst.ArticleTop.GetHashCode())
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
+                }
+                if (request.DataTypeValue == RankingListConst.Audio.GetHashCode())
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Audio.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                if (request.DataTypeValue == RankingListConst.HotComment.GetHashCode())
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
+                if (request.DataTypeValue == RankingListConst.CollectionBook.GetHashCode())
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.CollectCount));
+            }
+            query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
+            query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
+            result.Total = await _repository.CountAsync(query);
+            query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
+            query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
+            query.ForPage(request.Page, request.PerPage);
+            result.Items = await _repository.GetAllAsync<RankingListResult>(query);
+            return result;
+        }
+        /// <summary>
         /// 大咖讲座
         /// </summary>
         /// <returns></returns>

+ 10 - 4
gx_api/GxPress/Repository/GxPress.Repository.Interface/Media/IMediaRepository.cs

@@ -43,7 +43,7 @@ namespace GxPress.Repository.Interface.Media
         /// <param name="mediaId"></param>
         /// <returns></returns>
         Task<VideoMediaResult> GetVideoMediaResultAsync(int mediaId);
-        Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaLables,int page=1, int pageSize = 10);
+        Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaLables, int page = 1, int pageSize = 10);
         /// <summary>
         /// 猜你喜欢
         /// </summary>
@@ -100,15 +100,21 @@ namespace GxPress.Repository.Interface.Media
         /// </summary>
         /// <returns></returns>
         Task<SkillInfo> GetRandomDaySkillAsync();
-         /// <summary>
+        /// <summary>
         /// 猜你喜欢
         /// </summary>
         /// <returns></returns>
         Task<IEnumerable<MediaCathedraResult>> GetUserLikeAsync();
-         /// <summary>
+        /// <summary>
         /// 导航内容
         /// </summary>
         /// <returns></returns>
-       Task<PagedList<MediaCathedraResult>> GetContentNavigationAsync(MediaContentNavigationRequest request);
+        Task<PagedList<MediaCathedraResult>> GetContentNavigationAsync(MediaContentNavigationRequest request);
+        /// <summary>
+        /// 排行榜分页
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<PagedList<RankingListResult>> GetRankingPageListResults(RankingListRequest request);
     }
 }