李昊 4 years ago
parent
commit
83c1a88732

+ 2 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebMediaController.cs

@@ -15,7 +15,6 @@ 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
@@ -211,6 +210,8 @@ namespace GxPress.Api.WebControllers
         {
             var result = new RankingListCategoryResult();
             result.RankingListResults = await mediaRepository.GetRankingListResults(request);
+            foreach (var item in result.RankingListResults)
+                item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
             result.Category = new Dictionary<int, string>();
             Type t = typeof(RankingListConst);
             Array arrays = Enum.GetValues(t);

+ 18 - 13
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -13,6 +13,7 @@ using GxPress.Common.Exceptions;
 using GxPress.Common.Page;
 using GxPress.Request.Media;
 using System;
+using GxPress.EnumConst;
 
 namespace GxPress.Repository.Implement.Media
 {
@@ -459,36 +460,40 @@ namespace GxPress.Repository.Implement.Media
             if (request.DataTypeValue > 0)
             {
                 //1 热搜
-                if (request.DataTypeValue == 1)
+                if (request.DataTypeValue == RankingListConst.HotSearch.GetHashCode())
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
                 //2热书榜
-                if (request.DataTypeValue == 2)
+                if (request.DataTypeValue == RankingListConst.ReadBook.GetHashCode())
                 {
-                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 20);
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Book.GetHashCode());
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
                 }
-                if (request.DataTypeValue == 3)
+                //3 课程榜
+                if (request.DataTypeValue == RankingListConst.Article.GetHashCode())
                 {
-                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 100);
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
                 }
-                if (request.DataTypeValue == 4)
+                //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 == 5)
+                //文献头条
+                if (request.DataTypeValue == RankingListConst.ArticleTop.GetHashCode())
                 {
-                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 100);
-                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Article.GetHashCode());
+                    query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
                 }
-                if (request.DataTypeValue == 6)
+                if (request.DataTypeValue == RankingListConst.Audio.GetHashCode())
                 {
-                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), 40);
+                    query.Where(nameof(Entity.tede2.Media.Media.MediaType), ResourceTypeConst.Audio.GetHashCode());
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
                 }
-                if (request.DataTypeValue == 7)
+                if (request.DataTypeValue == RankingListConst.HotComment.GetHashCode())
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
-                if (request.DataTypeValue == 8)
+                if (request.DataTypeValue == RankingListConst.CollectionBook.GetHashCode())
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.CollectCount));
             }
             query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);