李昊 4 gadi atpakaļ
vecāks
revīzija
55a7af7807

+ 16 - 3
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminAppChannelController.cs

@@ -5,6 +5,7 @@ using GxPress.EnumConst;
 using GxPress.Repository.Interface.AppChannel;
 using GxPress.Request.AppChannel;
 using GxPress.Result.AppChannel;
+using GxPress.Service.Interface.AppChannel;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 
@@ -21,12 +22,13 @@ namespace GxPress.Api.AdminControllers
         private readonly IChannelCategoryMediaRepository channelCategoryMediaRepository;
         private readonly IChannelCategoryRepository channelCategoryRepository;
         private readonly IAppChannelRepository appChannelRepository;
-
-        public AdminAppChannelController(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository)
+        private readonly IAppChannelService appChannelService;
+        public AdminAppChannelController(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository, IAppChannelService appChannelService)
         {
             this.channelCategoryMediaRepository = channelCategoryMediaRepository;
             this.channelCategoryRepository = channelCategoryRepository;
             this.appChannelRepository = appChannelRepository;
+            this.appChannelService = appChannelService;
         }
         /// <summary>
         /// 获取导航详情
@@ -77,6 +79,7 @@ namespace GxPress.Api.AdminControllers
         {
             return await appChannelRepository.InsertAsync(model);
         }
+
         /// <summary>
         /// 获取导航分类详情
         /// </summary>
@@ -88,13 +91,23 @@ namespace GxPress.Api.AdminControllers
             return await channelCategoryRepository.GetAsync(id);
         }
         /// <summary>
+        ///修改导航分类
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPut("channel-category")]
+        public async Task<bool> ChannelCategoryUpdateAsync(ChannelCategory request)
+        {
+            return await channelCategoryRepository.UpdateAsync(request);
+        }
+        /// <summary>
         /// 查询导航分类
         /// </summary>
         /// <returns></returns>
         [HttpGet("channel-category/list/{appChannelId}")]
         public async Task<IEnumerable<ChannelCategoryResult>> ChannelCategoryGetAllAsync(int appChannelId)
         {
-            return await channelCategoryRepository.GetAllAsync(appChannelId);
+            return await appChannelService.GetAllAsync(appChannelId);
         }
         /// <summary>
         /// 删除导航分类

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

@@ -102,5 +102,10 @@ namespace GxPress.Result.AppChannel
         /// </summary>
         /// <value></value>
         public IEnumerable<ChannelCategoryResult> Children { get; set; }
+        /// <summary>
+        /// 媒体集合
+        /// </summary>
+        /// <value></value>
+        public IEnumerable<int> MediaIds { get; set; }
     }
 }

+ 2 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/AppChannel/ChannelCategoryMediaRepository.cs

@@ -67,6 +67,8 @@ namespace GxPress.Repository.Implement.AppChannel
             {
                 using (var tran = new TransactionScope())
                 {
+                    //删除
+                    await _repository.DeleteAsync(Q.Where(nameof(Entity.tede2.AppChannel.ChannelCategoryMedia.ChannelCategoryId),request.CategoryId));
                     foreach (var item in request.MediaIds)
                     {
                         await _repository.InsertAsync(new Entity.tede2.AppChannel.ChannelCategoryMedia { ChannelCategoryId = request.CategoryId, MediaId = item, IsCategory = request.IsCategory });

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

@@ -8,7 +8,6 @@ using Microsoft.Extensions.Options;
 using System.Threading.Tasks;
 using GxPress.Entity.tede2.AppChannel;
 using GxPress.Result.AppChannel;
-using GxPress.EnumConst;
 using System.Linq;
 
 namespace GxPress.Repository.Implement.AppChannel
@@ -75,5 +74,14 @@ namespace GxPress.Repository.Implement.AppChannel
         {
             return await _repository.InsertAsync(request) > 0;
         }
+        /// <summary>
+        ///修改导航分类
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public async Task<bool> UpdateAsync(ChannelCategory request)
+        {
+            return await _repository.UpdateAsync(request);
+        }
     }
 }

+ 6 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/AppChannel/IChannelCategoryRepository.cs

@@ -32,5 +32,11 @@ namespace GxPress.Repository.Interface.AppChannel
         /// <param name="model"></param>
         /// <returns></returns>
         Task<bool> InsertAsync(ChannelCategory request);
+        /// <summary>
+        ///修改导航分类
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        Task<bool> UpdateAsync(ChannelCategory request);
     }
 }

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

@@ -57,7 +57,13 @@ namespace GxPress.Service.Implement.AppChannel
         /// <returns></returns>
         public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)
         {
-            return await channelCategoryRepository.GetAllAsync(appChannelId);
+            var result = await channelCategoryRepository.GetAllAsync(appChannelId);
+            foreach (var item in result)
+            {
+                if (!item.IsChildren)
+                    item.MediaIds = await channelCategoryMediaRepository.GetAllAsync(item.Id);
+            }
+            return result;
         }
 
         /// <summary>
@@ -71,5 +77,7 @@ namespace GxPress.Service.Implement.AppChannel
             request.Ids = ids.ToList();
             return await mediaRepository.GetAppChannelsAsync(request);
         }
+
+
     }
 }