李昊 4 vuotta sitten
vanhempi
commit
3d77dd54b1

+ 1 - 1
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminAppChannelController.cs

@@ -43,7 +43,7 @@ namespace GxPress.Api.AdminControllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("channel/list/{channelTypeValye}")]
-        public async Task<IEnumerable<Entity.tede2.AppChannel.AppChannel>> GetAllAsync(int channelTypeValye)
+        public async Task<IEnumerable<AppChannelResult>> GetAllAsync(int channelTypeValye)
         {
             return await appChannelRepository.GetAllAsync((AppChannelConst)channelTypeValye);
         }

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

@@ -18,6 +18,8 @@ using GxPress.Repository.Interface.Category;
 using GxPress.Service.Interface.Media;
 using GxPress.Result.Navigation;
 using GxPress.Request.Navigation;
+using GxPress.Result.AppChannel;
+using GxPress.Service.Interface.AppChannel;
 
 namespace GxPress.Api.AppControllers
 {
@@ -33,12 +35,14 @@ namespace GxPress.Api.AppControllers
         private readonly IMediaRepository mediaRepository;
         private readonly IMediaService mediaService;
         private readonly ICategoryRepository categoryRepository;
-        public AppPageController(IAppHomePageService appHomePageService, IMediaRepository mediaRepository, ICategoryRepository categoryRepository, IMediaService mediaService)
+        private readonly IAppChannelService appChannelService;
+        public AppPageController(IAppHomePageService appHomePageService, IMediaRepository mediaRepository, ICategoryRepository categoryRepository, IMediaService mediaService, IAppChannelService appChannelService)
         {
             this.appHomePageService = appHomePageService;
             this.mediaRepository = mediaRepository;
             this.categoryRepository = categoryRepository;
             this.mediaService = mediaService;
+            this.appChannelService = appChannelService;
         }
 
         /// <summary>
@@ -278,5 +282,15 @@ namespace GxPress.Api.AppControllers
         {
             return await appHomePageService.GetNavigationSearchResultAsync(request);
         }
+        /// <summary>
+        /// 获取App频道
+        /// </summary>
+        /// /// <returns></returns>
+        [HttpGet("channel")]
+         [AllowAnonymous]
+        public async Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync()
+        {
+            return await appChannelService.GetAppChannelsAsync();
+        }
     }
 }

+ 55 - 0
gx_api/GxPress/Model/GxPress.Result/AppChannel/AppChannelResult.cs

@@ -3,11 +3,66 @@ using System.Collections.Generic;
 namespace GxPress.Result.AppChannel
 {
     /// <summary>
+    /// 频道
+    /// </summary>
+    public class AppChannelModelResult
+    {
+        /// <summary>
+        /// 频道类型 公众号  视频 期刊杂志 图书
+        /// </summary>
+        /// <value></value>
+
+        public GxPress.EnumConst.AppChannelConst Id { get; set; }
+        /// <summary>
+        /// 频道名称
+        /// </summary>
+        /// <value></value>
+        public string Name { get; set; }
+        /// <summary>
+        /// 频道集合
+        /// </summary>
+        /// <value></value>
+        public IEnumerable<AppChannelResult> Items { get; set; }
+    }
+    /// <summary>
     /// app导航
     /// </summary>
     public class AppChannelResult
     {
+        /// <summary>
+        /// id
+        /// </summary>
+        /// <value></value>
+        public int Id { get; set; }
+        /// <summary>
+        /// 标题图片
+        /// </summary>
+
+        public string ImageUrls { get; set; }
+        /// <summary>
+        /// 名称
+        /// </summary>
+        /// <value></value>
+
+        public string Name { get; set; }
+        /// <summary>
+        /// 类型 公众号  视频 期刊杂志 图书
+        /// </summary>
+        /// <value></value>
+
+        public GxPress.EnumConst.AppChannelConst ChannelTypeValue { get; set; }
+        /// <summary>
+        /// 排序
+        /// </summary>
+
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 1 普通 2 没有导航 3 sku
+        /// </summary>
+        /// <value></value>
 
+        public int TypeValue { get; set; }
     }
     /// <summary>
     /// 导航类别

+ 3 - 4
gx_api/GxPress/Repository/GxPress.Repository.Implement/AppChannel/AppChannelRepository.cs

@@ -6,6 +6,7 @@ using GxPress.Common.AppOptions;
 using GxPress.Common.Tools;
 using GxPress.EnumConst;
 using GxPress.Repository.Interface.AppChannel;
+using GxPress.Result.AppChannel;
 using Microsoft.Extensions.Options;
 
 namespace GxPress.Repository.Implement.AppChannel
@@ -43,13 +44,11 @@ namespace GxPress.Repository.Implement.AppChannel
         /// 查询
         /// </summary>
         /// <returns></returns>
-        public async Task<IEnumerable<Entity.tede2.AppChannel.AppChannel>> GetAllAsync(AppChannelConst channelTypeValue)
+        public async Task<IEnumerable<AppChannelResult>> GetAllAsync(AppChannelConst channelTypeValue)
         {
-            var result = await _repository.GetAllAsync(Q.Where(nameof(Entity.tede2.AppChannel.AppChannel.ChannelTypeValue), channelTypeValue).OrderBy(nameof(Entity.tede2.AppChannel.AppChannel.Sort)));
+            var result = await _repository.GetAllAsync<AppChannelResult>(Q.Where(nameof(Entity.tede2.AppChannel.AppChannel.ChannelTypeValue), channelTypeValue).OrderBy(nameof(Entity.tede2.AppChannel.AppChannel.Sort)));
             foreach (var item in result)
-            {
                 item.ImageUrls = StringUtils.AddDomain(item.ImageUrls);
-            }
             return result;
         }
         /// <summary>

+ 2 - 1
gx_api/GxPress/Repository/GxPress.Repository.Interface/AppChannel/IAppChannelRepository.cs

@@ -2,6 +2,7 @@ using System.Collections.Generic;
 using System.Threading.Tasks;
 using Datory;
 using GxPress.EnumConst;
+using GxPress.Result.AppChannel;
 
 namespace GxPress.Repository.Interface.AppChannel
 {
@@ -18,7 +19,7 @@ namespace GxPress.Repository.Interface.AppChannel
         /// 查询
         /// </summary>
         /// <returns></returns>
-        Task<IEnumerable<Entity.tede2.AppChannel.AppChannel>> GetAllAsync(AppChannelConst channelTypeValue);
+        Task<IEnumerable<AppChannelResult>> GetAllAsync(AppChannelConst channelTypeValue);
         /// <summary>
         /// 删除
         /// </summary>

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

@@ -1,6 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.EnumConst;
 using GxPress.Repository.Interface.AppChannel;
+using GxPress.Result.AppChannel;
 using GxPress.Service.Interface.AppChannel;
-
+using GxPress.Common.Tools;
 namespace GxPress.Service.Implement.AppChannel
 {
     /// <summary>
@@ -17,6 +22,27 @@ namespace GxPress.Service.Implement.AppChannel
             this.channelCategoryRepository = channelCategoryRepository;
             this.appChannelRepository = appChannelRepository;
         }
+        /// <summary>
+        /// 获取App频道
+        /// </summary>
+        /// <returns></returns>
+        public async Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync()
+        {
+            var result = new List<AppChannelModelResult>();
+            //递归频道
+            foreach (int v in Enum.GetValues(typeof(AppChannelConst)))
+            {
+                var constEnum = (AppChannelConst)v;
+                var appChannelModelResult = new AppChannelModelResult()
+                {
+                    Name = constEnum.GetDescriptionOriginal(),
+                    Id = constEnum,
+                    Items = await appChannelRepository.GetAllAsync(constEnum)
+                };
+                result.Add(appChannelModelResult);
+            }
+            return result;
+        }
 
     }
 }

+ 10 - 2
gx_api/GxPress/Service/GxPress.Service.Interface/AppChannel/IAppChannelService.cs

@@ -1,7 +1,15 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.Result.AppChannel;
+
 namespace GxPress.Service.Interface.AppChannel
 {
-    public interface IAppChannelService:IService
+    public interface IAppChannelService : IService
     {
-         
+        /// <summary>
+        /// 获取App频道
+        /// </summary>
+        /// <returns></returns>
+        Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync();
     }
 }