李昊 4 years ago
parent
commit
c7d5d12539

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

@@ -329,5 +329,16 @@ namespace GxPress.Api.AppControllers
             }
             return await appChannelService.GetChannelCategoryMediaPageAsync(request);
         }
+
+        /// <summary>
+        /// 书籍SKU
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("sku")]
+        [AllowAnonymous]
+        public async Task<SkuResult> SkuResultAsync()
+        {
+            return await appHomePageService.SkuResultAsync();
+        }
     }
 }

+ 10 - 0
gx_api/GxPress/Model/GxPress.Request/AppChannel/AppChannelRequest.cs

@@ -28,6 +28,16 @@ namespace GxPress.Request.AppChannel
         public int CategoryId { get; set; }
 
         public List<int> Ids { get; set; }
+        /// <summary>
+        /// 条件筛选
+        /// </summary>
+        /// <value></value>
+        public int SortSift { get; set; }
+        /// <summary>
+        /// 出版社
+        /// </summary>
+        /// <value></value>
+        public IEnumerable<string> PressSift { get; set; }
     }
     /// <summary>
     /// 添加

+ 41 - 1
gx_api/GxPress/Model/GxPress.Result/AppChannel/AppChannelResult.cs

@@ -200,4 +200,44 @@ namespace GxPress.Result.AppChannel
 
         public string ExpandName { get; set; }
     }
-}
+    /// <summary>
+    /// 书籍SKU
+    /// </summary>
+    public class SkuResult
+    {
+        public IEnumerable<SortSift> SortSift { get; set; }
+        public IEnumerable<PressSift> PressSift { get; set; }
+    }
+    /// <summary>
+    /// 排序条件筛选
+    /// </summary>
+    public class SortSift
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int Key { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public string Value { get; set; }
+    }
+    /// <summary>
+    /// 条件筛选出版社
+    /// </summary>
+    public class PressSift
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int Key { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public string Value { get; set; }
+    }
+}

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

@@ -930,6 +930,17 @@ namespace GxPress.Repository.Implement.Media
             query.Select(nameof(Entity.tede2.Media.Media.Summary));
             query.Select(nameof(Entity.tede2.Media.Media.CommentScore));
             query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.Ids);
+            //最热
+            if (request.SortSift == 1)
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.ReadCount));
+            //最新
+            if (request.SortSift == 2)
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
+            //好评
+            if (request.SortSift == 3)
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.CommentScore));
+            if (request.PressSift.Count() > 0)
+                query.WhereIn(nameof(Entity.tede2.Media.Media.Press), request.PressSift);
             if (!string.IsNullOrEmpty(request.KeyWord))
                 query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
             resut.Total = await _repository.CountAsync(query);
@@ -946,5 +957,18 @@ namespace GxPress.Repository.Implement.Media
                 item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
             return resut;
         }
+        /// <summary>
+        /// 获取出版社
+        /// </summary>
+        /// <returns></returns>
+        public async Task<IEnumerable<string>> GetPresssAsync()
+        {
+            var query = Q.NewQuery();
+            query.Where(nameof(Entity.tede2.Media.Media.Id), ">", 0);
+            query.GroupBy(nameof(Entity.tede2.Media.Media.Press));
+            query.Select(nameof(Entity.tede2.Media.Media.Press));
+            query.Where(nameof(Entity.tede2.Media.Media.Press), "<>", "");
+            return await _repository.GetAllAsync<string>(query);
+        }
     }
 }

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

@@ -133,5 +133,10 @@ namespace GxPress.Repository.Interface.Media
         /// </summary>
         /// <returns></returns>
         Task<PagedList<MediaChannelCategoryResult>> GetAppChannelsAsync(AppChannelSearchRequest request);
+        /// <summary>
+        /// 获取出版社
+        /// </summary>
+        /// <returns></returns>
+        Task<IEnumerable<string>> GetPresssAsync();
     }
 }

+ 27 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/AppHomePage/AppHomePageService.Sku.cs

@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.Result.AppChannel;
+
+namespace GxPress.Service.Implement.AppHomePage
+{
+    public partial class AppHomePageService
+    {
+        /// <summary>
+        /// 书籍SKU
+        /// </summary>
+        /// <returns></returns>
+        public async Task<SkuResult> SkuResultAsync()
+        {
+            var result = new SkuResult();
+            result.SortSift = new List<SortSift>() {new SortSift{Key=0,Value="全部"}
+            ,new SortSift{Key=1,Value="最热"} ,new SortSift{Key=2,Value="最新"},new SortSift{Key=3,Value="好评"}};
+            //出版社
+            var pressList = await mediaRepository.GetPresssAsync();
+            var PressSiftList = new List<PressSift>();
+            foreach (var item in pressList)
+                PressSiftList.Add(new PressSift { Key = 0, Value = item });
+            result.PressSift = PressSiftList;
+            return result;
+        }
+    }
+}

+ 7 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/AppHomePage/IAppHomePageService.cs

@@ -5,6 +5,7 @@ using GxPress.Request.ArticleGroup;
 using GxPress.Request.Media;
 using GxPress.Request.Navigation;
 using GxPress.Request.TeacherRequest;
+using GxPress.Result.AppChannel;
 using GxPress.Result.Media;
 using GxPress.Result.Navigation;
 using GxPress.Result.SystemLabel;
@@ -86,5 +87,11 @@ namespace GxPress.Service.Interface.AppHomePage
         /// <param name="request"></param>
         /// <returns></returns>
         Task<NavigationSearchResult> GetNavigationSearchResultAsync(NavigationSearchRequest request);
+
+        /// <summary>
+        /// 书籍SKU
+        /// </summary>
+        /// <returns></returns>
+        Task<SkuResult> SkuResultAsync();
     }
 }