李昊 il y a 4 ans
Parent
commit
33ed1247cc

+ 20 - 1
gx_api/GxPress/Api/GxPress.Api/AppControllers/AppPageController.cs

@@ -20,6 +20,7 @@ using GxPress.Result.Navigation;
 using GxPress.Request.Navigation;
 using GxPress.Result.AppChannel;
 using GxPress.Service.Interface.AppChannel;
+using GxPress.Request.AppChannel;
 
 namespace GxPress.Api.AppControllers
 {
@@ -287,10 +288,28 @@ namespace GxPress.Api.AppControllers
         /// </summary>
         /// /// <returns></returns>
         [HttpGet("channel")]
-         [AllowAnonymous]
+        [AllowAnonymous]
         public async Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync()
         {
             return await appChannelService.GetAppChannelsAsync();
         }
+        /// <summary>
+        /// 查询 获取频道分类
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("channel-category/{appChannelId}")]
+        public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)
+        {
+            return await appChannelService.GetAllAsync(appChannelId);
+        }
+        /// <summary>
+        /// 根据频道分类ID
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("channel-category-media")]
+        public async Task<PagedList<MediaCathedraResult>> GetChannelCategoryMediaPageAsync(AppChannelSearchRequest request)
+        {
+            return await appChannelService.GetChannelCategoryMediaPageAsync(request);
+        }
     }
 }

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

@@ -20,5 +20,11 @@ namespace GxPress.Entity.tede2.AppChannel
         /// <value></value>
         [DataColumn]
         public int MediaId { get; set; }
+        /// <summary>
+        /// 是否分类
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public bool IsCategory { get; set; }
     }
 }

+ 20 - 1
gx_api/GxPress/Model/GxPress.Request/AppChannel/AppChannelRequest.cs

@@ -7,16 +7,35 @@ namespace GxPress.Request.AppChannel
 
     }
     /// <summary>
+    /// 
+    /// </summary>
+    public class AppChannelSearchRequest : Common.Page.PageParameter
+    {
+        public string KeyWord { get; set; }
+        /// <summary>
+        /// 分类ID
+        /// </summary>
+        /// <value></value>
+        public int CategoryId { get; set; }
+
+        public List<int> Ids { get; set; }
+    }
+    /// <summary>
     /// 添加
     /// </summary>
     public class ChannelCategoryMediaInRequest
     {
         /// <summary>
-        /// 
+        /// 对应分类ID 如果不是分类对应频道ID
         /// </summary>
         /// <value></value>
         public int CategoryId { get; set; }
         /// <summary>
+        /// 是否分类
+        /// </summary>
+        /// <value></value>
+        public bool IsCategory { get; set; }
+        /// <summary>
         /// 资源ID
         /// </summary>
         /// <value></value>

+ 1 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/AppChannel/ChannelCategoryMediaRepository.cs

@@ -69,7 +69,7 @@ namespace GxPress.Repository.Implement.AppChannel
                 {
                     foreach (var item in request.MediaIds)
                     {
-                        await _repository.InsertAsync(new Entity.tede2.AppChannel.ChannelCategoryMedia { ChannelCategoryId = request.CategoryId, MediaId = item });
+                        await _repository.InsertAsync(new Entity.tede2.AppChannel.ChannelCategoryMedia { ChannelCategoryId = request.CategoryId, MediaId = item, IsCategory = request.IsCategory });
                     }
                     tran.Complete();
                 }

+ 1 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/AppChannel/ChannelCategoryRepository.cs

@@ -39,7 +39,7 @@ namespace GxPress.Repository.Implement.AppChannel
             return result;
         }
         /// <summary>
-        /// 查询 获取MediaId
+        /// 查询 获取频道分类
         /// </summary>
         /// <returns></returns>
         public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)

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

@@ -16,6 +16,7 @@ using System;
 using GxPress.EnumConst;
 using GxPress.Request.ArticleGroup;
 using Dapper;
+using GxPress.Request.AppChannel;
 
 namespace GxPress.Repository.Implement.Media
 {
@@ -907,5 +908,37 @@ namespace GxPress.Repository.Implement.Media
             }
             return reuslt;
         }
+
+        /// <summary>
+        /// app频道
+        /// </summary>
+        /// <returns></returns>
+        public async Task<PagedList<MediaCathedraResult>> GetAppChannelsAsync(AppChannelSearchRequest request)
+        {
+            var resut = 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.Select(nameof(Entity.tede2.Media.Media.Summary));
+            query.WhereIn(nameof(Entity.tede2.Media.Media.Id), request.Ids);
+            if (!string.IsNullOrEmpty(request.KeyWord))
+                query.WhereLike(nameof(Entity.tede2.Media.Media.Title), $"%{request.KeyWord}%");
+            resut.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);
+            resut.Items = await _repository.GetAllAsync<MediaCathedraResult>(query);
+            return resut;
+        }
     }
 }

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

@@ -2,6 +2,7 @@
 using System.Threading.Tasks;
 using Datory;
 using GxPress.Common.Page;
+using GxPress.Request.AppChannel;
 using GxPress.Request.ArticleGroup;
 using GxPress.Request.Media;
 using GxPress.Result.Media;
@@ -126,5 +127,10 @@ namespace GxPress.Repository.Interface.Media
         /// </summary>
         /// <returns></returns>
         Task<IEnumerable<MediaCathedraResult>> GetStarLablesAsync(MediaStarLableRequest request);
+        /// <summary>
+        /// app频道
+        /// </summary>
+        /// <returns></returns>
+        Task<PagedList<MediaCathedraResult>> GetAppChannelsAsync(AppChannelSearchRequest request);
     }
 }

+ 28 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/AppChannel/AppChannelService.cs

@@ -6,6 +6,12 @@ using GxPress.Repository.Interface.AppChannel;
 using GxPress.Result.AppChannel;
 using GxPress.Service.Interface.AppChannel;
 using GxPress.Common.Tools;
+using GxPress.Result.Media;
+using GxPress.Request.AppChannel;
+using GxPress.Repository.Interface.Media;
+using System.Linq;
+using GxPress.Common.Page;
+
 namespace GxPress.Service.Implement.AppChannel
 {
     /// <summary>
@@ -16,11 +22,13 @@ namespace GxPress.Service.Implement.AppChannel
         private readonly IChannelCategoryMediaRepository channelCategoryMediaRepository;
         private readonly IChannelCategoryRepository channelCategoryRepository;
         private readonly IAppChannelRepository appChannelRepository;
-        public AppChannelService(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository)
+        private readonly IMediaRepository mediaRepository;
+        public AppChannelService(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository, IMediaRepository mediaRepository)
         {
             this.channelCategoryMediaRepository = channelCategoryMediaRepository;
             this.channelCategoryRepository = channelCategoryRepository;
             this.appChannelRepository = appChannelRepository;
+            this.mediaRepository = mediaRepository;
         }
         /// <summary>
         /// 获取App频道
@@ -43,6 +51,25 @@ namespace GxPress.Service.Implement.AppChannel
             }
             return result;
         }
+        /// <summary>
+        /// 查询 获取频道分类
+        /// </summary>
+        /// <returns></returns>
+        public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)
+        {
+            return await channelCategoryRepository.GetAllAsync(appChannelId);
+        }
 
+        /// <summary>
+        /// 根据app频道分类id获取媒体分页数据
+        /// </summary>
+        /// <returns></returns>
+        public async Task<PagedList<MediaCathedraResult>> GetChannelCategoryMediaPageAsync(AppChannelSearchRequest request)
+        {
+            //获取标签
+            var ids = await channelCategoryMediaRepository.GetAllAsync(request.CategoryId);
+            request.Ids = ids.ToList();
+            return await mediaRepository.GetAppChannelsAsync(request);
+        }
     }
 }

+ 13 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/AppChannel/IAppChannelService.cs

@@ -1,6 +1,9 @@
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using GxPress.Common.Page;
+using GxPress.Request.AppChannel;
 using GxPress.Result.AppChannel;
+using GxPress.Result.Media;
 
 namespace GxPress.Service.Interface.AppChannel
 {
@@ -11,5 +14,15 @@ namespace GxPress.Service.Interface.AppChannel
         /// </summary>
         /// <returns></returns>
         Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync();
+        /// <summary>
+        /// 查询 获取频道分类
+        /// </summary>
+        /// <returns></returns>
+        Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId);
+         /// <summary>
+        /// 根据app频道分类id获取媒体分页数据
+        /// </summary>
+        /// <returns></returns>
+        Task<PagedList<MediaCathedraResult>> GetChannelCategoryMediaPageAsync(AppChannelSearchRequest request);
     }
 }