李昊 4 éve
szülő
commit
1e04af47e3

+ 7 - 0
gx_api/GxPress/Model/GxPress.Entity/SystemLabel/SystemLabel.cs

@@ -55,6 +55,13 @@ namespace GxPress.Entity.SystemLabel
         /// <value></value>
         [DataColumn]
         public bool IsPage { get; set; }
+
+        /// <summary>
+        /// 分页条数
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int PageSize { get; set; }
         /// <summary>
         /// 路径
         /// </summary>

+ 6 - 1
gx_api/GxPress/Model/GxPress.Request/SystemLabel/SystemLabelRequest.cs

@@ -62,6 +62,11 @@ namespace GxPress.Request.SystemLabel
 
         public int IsPage { get; set; }
         /// <summary>
+        /// 分页条数
+        /// </summary>
+        /// <value></value>
+        public int PageSize { get; set; }
+        /// <summary>
         /// 路径
         /// </summary>
         /// <value></value>
@@ -86,7 +91,7 @@ namespace GxPress.Request.SystemLabel
         /// <value></value>
 
         public string StyleType { get; set; }
-         /// <summary>
+        /// <summary>
         /// 是否显示标签名称 1 设置 2取消
         /// </summary>
         /// <value></value>

+ 5 - 1
gx_api/GxPress/Model/GxPress.Result/Navigation/NavigationResult.cs

@@ -47,7 +47,11 @@ namespace GxPress.Result.Navigation
         /// <value></value>
 
         public bool IsSkip { get; set; }
-
+        /// <summary>
+        /// 分页条数
+        /// </summary>
+        /// <value></value>
+        public int PageSize { get; set; }
         /// <summary>
         /// 是否分页
         /// </summary>

+ 5 - 0
gx_api/GxPress/Model/GxPress.Result/SystemLabel/SystemLabelResult.cs

@@ -58,6 +58,11 @@ namespace GxPress.Result.SystemLabel
 
         public bool IsPage { get; set; }
         /// <summary>
+        /// 分页条数
+        /// </summary>
+        /// <value></value>
+        public int PageSize { get; set; }
+        /// <summary>
         /// 路径
         /// </summary>
         /// <value></value>

+ 2 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -380,7 +380,7 @@ namespace GxPress.Repository.Implement.Media
         /// </summary>
         /// <param name="mediaIds"></param>
         /// <returns></returns>
-        public async Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaIds)
+        public async Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaIds, int pageSize = 10)
         {
             //获取媒体
             var query = Q.NewQuery();
@@ -398,7 +398,7 @@ namespace GxPress.Repository.Implement.Media
             query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
             query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
             query.OrderByDesc(nameof(Entity.tede2.Media.Media.LastModifiedDate));
-            query.ForPage(1, 10);
+            query.ForPage(1, pageSize);
             return await _repository.GetAllAsync<NavigationMediaResult>(query);
         }
         /// <summary>

+ 2 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/SystemLabel/SystemLabelRepository.cs

@@ -76,6 +76,8 @@ namespace GxPress.Repository.Implement.SystemLabel
                     model.StyleType = request.StyleType;
                 if (request.IsShowLabelName > 0)
                     model.IsShowLabelName = request.IsShowLabelName == 1;
+                if (request.PageSize > 0)
+                    model.PageSize = request.PageSize;
                 return await _repository.UpdateAsync(model);
             }
             return false;

+ 6 - 4
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -296,7 +296,7 @@ namespace GxPress.Repository.Implement
             connection.Dispose();
             return result;
         }
-
+         
         public async Task<PagedList<TopicListPageResult>> GetTopicByGroupAsync(TopicPageSearchRequest request)
         {
             var sql = $@"SELECT 
@@ -374,9 +374,11 @@ namespace GxPress.Repository.Implement
                                     OR a.Title LIKE '%{request.Keyword}%'
                                     OR a.HtmlContent LIKE '%{request.Keyword}%')";
             }
-            sql += $@"  ORDER BY a.CreatedDate DESC
-                        LIMIT {(request.Page - 1) * request.PerPage} , {request.PerPage}";
-
+            if (!string.IsNullOrEmpty(request.Sort))
+                sql += $@" ORDER BY a.ReadCount DESC";
+            else
+                sql += $@" ORDER BY a.CreatedDate DESC";
+            sql += $@" LIMIT {(request.Page - 1) * request.PerPage} , {request.PerPage}";
             var result = new PagedList<TopicListPageResult>();
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);

+ 1 - 1
gx_api/GxPress/Repository/GxPress.Repository.Interface/Media/IMediaRepository.cs

@@ -42,7 +42,7 @@ namespace GxPress.Repository.Interface.Media
         /// <param name="mediaId"></param>
         /// <returns></returns>
         Task<VideoMediaResult> GetVideoMediaResultAsync(int mediaId);
-        Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaLables);
+        Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaLables,int pageSize=10);
         /// <summary>
         /// 猜你喜欢
         /// </summary>

+ 2 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Navigation/NavigationService.cs

@@ -82,6 +82,7 @@ namespace GxPress.Service.Implement.Navigation
                             StyleType = item.StyleType,
                             ActionUrl = item.ActionUrl,
                             ControllerUrl = item.ControllerUrl,
+                            PageSize=item.PageSize,
                             IsPage = item.IsPage,
                             IsSkip = item.IsSkip,
                             LabelName = item.LabelName,
@@ -112,7 +113,7 @@ namespace GxPress.Service.Implement.Navigation
                         }
                         //获取媒体标签
                         var mediaIds = await _mediaLableRepository.GetMediaIdsAysnc(item.Id);
-                        var medias = await _mediaRepository.GetNavigationMediaResults(mediaIds);
+                        var medias = await _mediaRepository.GetNavigationMediaResults(mediaIds,item.PageSize);
                         navigationLabelMediaResult.MediaResults = medias.ToList();
                         foreach (var itemMedia in navigationLabelMediaResult.MediaResults)
                             itemMedia.ImageUrls = StringUtils.AddDomain(itemMedia.ImageUrls);