李昊 4 years ago
parent
commit
d28d4c2f50

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

@@ -72,5 +72,15 @@ namespace GxPress.Api.AppControllers
             request.MediaType = GxPress.EnumConst.AllTypeConst.Audio.GetHashCode();
             return await appHomePageService.GetDayGoodTextAsync(request);
         }
+
+        /// <summary>
+        /// 根据标签ID获取每日好书
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("lable")]
+        public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
+        {
+            return await appHomePageService.GetMediaByLableIdsAsync(request);
+        }
     }
 }

+ 16 - 0
gx_api/GxPress/Model/GxPress.Request/ArticleGroup/ArticleGroupRequest.cs

@@ -10,5 +10,21 @@ namespace GxPress.Request.ArticleGroup
         /// </summary>
         /// <value></value>
         public string StyleCss{get;set;}
+
+         /// <summary>
+        /// 是否分页
+        /// </summary>
+        /// <value></value>
+        public bool IsPage{get;set;}
+          /// <summary>
+        /// 请求路径
+        /// </summary>
+        /// <value></value>
+        public string ActionUrl{get;set;}
+         /// <summary>
+        /// 请求类型
+        /// </summary>
+        /// <value></value>
+        public string Method { get; set; }
     }
 }

+ 9 - 1
gx_api/GxPress/Model/GxPress.Request/Media/MediaRequest.cs

@@ -251,6 +251,14 @@ namespace GxPress.Request.Media
         /// <value></value>
         public int DataTypeValue { get; set; }
     }
+    /// <summary>
+    /// 
+    /// </summary>
+    public class MediaIdsRequest : Common.Page.PageParameter
+    {
+        public int LableId { get; set; }
+        public List<int> Ids { get; set; }
+    }
+
 
-    
 }

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

@@ -220,6 +220,35 @@ namespace GxPress.Repository.Implement.Media
             return result;
         }
 
+        /// <summary>
+        /// 根据IDs
+        /// </summary>
+        /// <returns></returns>
+        public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
+        {
+            var result = new PagedList<MediaCathedraResult>();
+            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.Author));
+            query.Select(nameof(Entity.tede2.Media.Media.MediaType));
+            query.Select(nameof(Entity.tede2.Media.Media.ReadCount));
+            query.Select(nameof(Entity.tede2.Media.Media.CreatedDate));
+            query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.Ids);
+            result.Total = await _repository.CountAsync(query);
+            if (!string.IsNullOrEmpty(request.Sort))
+            {
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
+            }
+            else
+                query.OrderByDesc(nameof(Entity.tede2.Media.Media.CreatedDate));
+            query.ForPage(request.Page, request.PerPage);
+            result.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
+            return result;
+        }
+
         public async Task<bool> UpdateAsync(MediaResult result)
         {
             //var model = _mapper.Map<Entity.tede2.Media.Media>(result);

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

@@ -79,5 +79,10 @@ namespace GxPress.Repository.Interface.Media
         /// </summary>
         /// <returns></returns>
         Task<int> GetMediasByTeacherCountAsync(ArticleGroupRequest request);
+        /// <summary>
+        /// 根据IDs
+        /// </summary>
+        /// <returns></returns>
+       Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request);
     }
 }

+ 29 - 3
gx_api/GxPress/Service/GxPress.Service.Implement/AppHomePage/AppHomePageService.cs

@@ -64,10 +64,24 @@ namespace GxPress.Service.Implement.AppHomePage
             {
                 return await GetVipSupplyAsync(request);
             }
-
+            //每日好书
+            if (request.StyleCss == "DayGoodBook")
+            {
+                return await GetDayGoodBookAsync(request);
+            }
             return results;
         }
         /// <summary>
+        /// 每日好书
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<List<AppLabelResult<MediaCathedraResult>>> GetDayGoodBookAsync(ArticleGroupRequest request)
+        {
+            request.ActionUrl = "api/app/page/lable";
+            return await GetVipSupplyAsync(request);
+        }
+        /// <summary>
         /// 每日好文
         /// </summary>
         /// <param name="request"></param>
@@ -125,11 +139,13 @@ namespace GxPress.Service.Implement.AppHomePage
                     //获取常规数据
                     var mediaCathedraResult = new AppLabelResult<MediaCathedraResult>()
                     {
-                        IsPage = false,
+                        IsPage = item.IsPage,
                         Id = item.Id,
                         LabelName = item.LabelName,
                         ResourceType = 40,
-                        Items = list
+                        Items = list,
+                        Method = item.IsPage ? "post" : "",
+                        ActionUrl = item.IsPage ? request.ActionUrl : ""
                     };
                     result.Add(mediaCathedraResult);
                 }
@@ -151,5 +167,15 @@ namespace GxPress.Service.Implement.AppHomePage
             result.Total = await mediaRepository.GetMediasByTeacherCountAsync(request);
             return result;
         }
+        /// <summary>
+        /// 根据IDs
+        /// </summary>
+        /// <returns></returns>
+        public async Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request)
+        {
+            var ids = await _mediaLableRepository.GetMediaIdsAysnc(request.LableId);
+            request.Ids = ids.ToList();
+            return await mediaRepository.GetMediaByLableIdsAsync(request);
+        }
     }
 }

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

@@ -27,5 +27,10 @@ namespace GxPress.Service.Interface.AppHomePage
         /// <param name="request"></param>
         /// <returns></returns>
         Task<PagedList<MediaCathedraResult>> GetDayGoodTextAsync(MediaSearchRequest request);
+        /// <summary>
+        /// 根据IDs
+        /// </summary>
+        /// <returns></returns>
+       Task<PagedList<MediaCathedraResult>> GetMediaByLableIdsAsync(MediaIdsRequest request);
     }
 }