李昊 před 4 roky
rodič
revize
735fd6d9ba

+ 27 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebMediaController.cs

@@ -13,6 +13,11 @@ using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.Net.Http.Headers;
 using GxPress.Repository.Interface.Order;
+using System.Collections.Generic;
+using GxPress.EnumConst;
+using System.Reflection;
+using GxPress.Common.Tools;
+
 namespace GxPress.Api.WebControllers
 {
     /// <summary>
@@ -195,5 +200,27 @@ namespace GxPress.Api.WebControllers
             var str = @"wwwroot/123456.txt";
             return Common.Tools.HtmlAgilityPackHelper.GetHmtlContent(str);
         }
+        /// <summary>
+        /// 排行榜
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("ranking-list")]
+        [AllowAnonymous]
+        public async Task<RankingListCategoryResult> GetRankingListResults(RankingListRequest request)
+        {
+            var result = new RankingListCategoryResult();
+            result.RankingListResults = await mediaRepository.GetRankingListResults(request);
+            result.Category = new Dictionary<int, string>();
+            Type t = typeof(RankingListConst);
+            Array arrays = Enum.GetValues(t);
+            for (int i = 0; i < arrays.LongLength; i++)
+            {
+                RankingListConst test = (RankingListConst)arrays.GetValue(i);
+                result.Category.Add((int)test, test.GetDescriptionOriginal());
+            }
+            return result;
+        }
+
     }
 }

+ 6 - 0
gx_api/GxPress/Model/GxPress.Entity/tede2/Media/Media.cs

@@ -261,5 +261,11 @@ namespace GxPress.Entity.tede2.Media
         /// <value></value>
         [DataColumn]
         public int OrderCount { get; set; }
+        /// <summary>
+        /// 评论分数
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public decimal CommentScore { get; set; }
     }
 }

+ 27 - 0
gx_api/GxPress/Model/GxPress.EnumConst/RankingListConst.cs

@@ -0,0 +1,27 @@
+using System.ComponentModel;
+
+namespace GxPress.EnumConst
+{
+    /// <summary>
+    /// 1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条  6试听榜 7大众热评 8Top 100 专著
+    /// </summary>
+    public enum RankingListConst
+    {
+        [Description("热搜")]
+        HotSearch = 1,
+        [Description("热书榜")]
+        ReadBook = 2,
+        [Description("课程榜")]
+        Article = 3,
+        [Description("Top100新书")]
+        NewBook = 4,
+        [Description("文献头条")]
+        ArticleTop = 5,
+        [Description("试听榜")]
+        Audio = 6,
+        [Description("大众热评")]
+        HotComment = 7,
+        [Description("Top100专著")]
+        CollectionBook = 8
+    }
+}

+ 1 - 1
gx_api/GxPress/Model/GxPress.EnumConst/VipTypeConst.cs

@@ -52,7 +52,7 @@ namespace GxPress.EnumConst
         Vip = 2,
     }
     /// <summary>
-    /// 资源类型 文章100书籍20,课程30,音频40,期刊50,视频60,名栏90,公众号110,刊期120 ,榜单 130 示范客厅 140  品牌专区1 150 品牌专区2 160
+    /// 资源类型 文章100书籍20,课程30,音频40,期刊50,视频60,名栏90,公众号110,刊期120 ,榜单 130 示范课堂 140  品牌专区1 150 品牌专区2 160
     /// </summary>
     public enum ResourceTypeConst
     {

+ 11 - 0
gx_api/GxPress/Model/GxPress.Request/Media/MediaRequest.cs

@@ -240,4 +240,15 @@ namespace GxPress.Request.Media
         /// <value></value>
         public int UserId { get; set; }
     }
+    /// <summary>
+    /// 排行榜
+    /// </summary>
+    public class RankingListRequest : Common.Page.PageParameter
+    {
+        /// <summary>
+        ///  1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条  6试听榜 7大众热评 8Top 100 专著
+        /// </summary>
+        /// <value></value>
+        public int DataTypeValue { get; set; }
+    }
 }

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

@@ -50,6 +50,61 @@ namespace GxPress.Result.Media
 
     }
     /// <summary>
+    /// 排行榜
+    /// </summary>
+    public class RankingListResult
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int Id { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        /// <value></value>
+        public string AutoNumber { get; set; }
+        /// <summary>
+        /// 媒体类型
+        /// </summary>
+        public int MediaType { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 标题图片
+        /// </summary>
+        public string ImageUrls { get; set; }
+
+        /// <summary>
+        /// 简介
+        /// </summary>
+        public string Summary { get; set; }
+
+        /// <summary>
+        /// 作者
+        /// </summary>
+        public string Author { get; set; }
+        /// <summary>
+        /// 名师ID
+        /// </summary>
+        /// <value></value>
+        public int TeacherId { get; set; }
+        /// <summary>
+        /// 评分
+        /// </summary>
+        public decimal CommentScore { get; set; }
+    }
+
+    public class RankingListCategoryResult
+    {
+        public IEnumerable<RankingListResult> RankingListResults { get; set; }
+
+        public Dictionary<int, string> Category { get; set; }
+    }
+    /// <summary>
     /// 媒体
     /// </summary>
     public class MediaResult

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

@@ -436,5 +436,67 @@ namespace GxPress.Repository.Implement.Media
             query.ForPage(1, 10);
             return await _repository.GetAllAsync<NavigationMediaResult>(query);
         }
+        /// <summary>
+        /// 排行榜
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<RankingListResult>> GetRankingListResults(RankingListRequest request)
+        {
+            //获取媒体
+            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));
+            //1 热搜 2热书榜 3 课程榜 4Top 100 新书 5文献头条  6试听榜 7大众热评 8Top 100 专著
+            if (request.DataTypeValue > 0)
+            {
+                //1 热搜
+                if (request.DataTypeValue == 1)
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                //2热书榜
+                if (request.DataTypeValue == 2)
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 20);
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                if (request.DataTypeValue == 3)
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 100);
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                if (request.DataTypeValue == 4)
+                {
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
+                }
+                if (request.DataTypeValue == 5)
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 100);
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                if (request.DataTypeValue == 6)
+                {
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 40);
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                }
+                if (request.DataTypeValue == 7)
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
+                if (request.DataTypeValue == 8)
+                    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);
+            query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
+            query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
+            query.ForPage(request.Page, request.PerPage);
+            return await _repository.GetAllAsync<RankingListResult>(query);
+        }
     }
 }

+ 7 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/Media/IMediaRepository.cs

@@ -55,5 +55,12 @@ namespace GxPress.Repository.Interface.Media
         /// <param name="mediaIds"></param>
         /// <returns></returns>
         Task<IEnumerable<NavigationMediaResult>> GetRecommendMediaResults();
+
+         /// <summary>
+        /// 排行榜
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+         Task<IEnumerable<RankingListResult>> GetRankingListResults(RankingListRequest request);
     }
 }