李昊 4 lat temu
rodzic
commit
fef80b06f6

+ 12 - 2
gx_api/GxPress/Api/GxPress.Api/WebControllers/NavigationController.cs

@@ -18,10 +18,10 @@ namespace GxPress.Api.WebControllers
     {
         private readonly INavigationRepository navigationRepository;
         private readonly INavigationService navigationService;
-        public NavigationController(INavigationRepository navigationRepository,INavigationService navigationService)
+        public NavigationController(INavigationRepository navigationRepository, INavigationService navigationService)
         {
             this.navigationRepository = navigationRepository;
-            this.navigationService=navigationService;
+            this.navigationService = navigationService;
         }
         /// <summary>
         /// 获取导航栏数据
@@ -33,6 +33,16 @@ namespace GxPress.Api.WebControllers
         {
             return await navigationService.GetNavigationResults(id);
         }
+        /// <summary>
+        /// 获取中间页面数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("middle-lable/{id}")]
+        [AllowAnonymous]
+        public async Task<MiddleLableResult> GetMiddleLableResults(int middleLableId)
+        {
+            return await navigationService.GetMiddleLableResults(middleLableId);
+        }
 
         /// <summary>
         /// 列表 pc 1 移动 2

+ 65 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Navigation/NavigationService.cs

@@ -103,5 +103,70 @@ namespace GxPress.Service.Implement.Navigation
             }
             return result;
         }
+        /// <summary>
+        /// 获取中间页面数据
+        /// </summary>
+        /// <returns></returns>
+        public async Task<MiddleLableResult> GetMiddleLableResults(int middleLableId)
+        {
+            var result = new MiddleLableResult();
+            //获取中间页面
+            var middleLable = await _middleLableRepository.GetAsync(middleLableId);
+            if (string.IsNullOrEmpty(middleLable.LabelId))
+                return result;
+            result = _mapper.Map<MiddleLableResult>(middleLable);
+            result.NavigationLabelMediaResults = new List<NavigationLabelMediaResult>();
+            //获取轮播
+            if (middleLable.IsSlide)
+            {
+                if (result.IsSlide)
+                {
+                    result.Sildes = await slideRepository.GetListAsync(result.TypeId);
+                    foreach (var item in result.Sildes)
+                        item.ImageUrl = StringUtils.AddDomain(item.ImageUrl);
+                }
+            }
+            //获取标签
+            var systemLabels = await _systemLabelRepository.GetAllAsync(StringUtils.StringCollectionToIntList(middleLable.LabelId).ToList());
+            foreach (var item in systemLabels)
+            {
+                //获取常规数据
+                var navigationLabelMediaResult = new NavigationLabelMediaResult()
+                {
+                    Id = item.Id,
+                    Sort = item.Sort,
+                    StyleType = item.StyleType,
+                    ActionUrl = item.ActionUrl,
+                    ControllerUrl = item.ControllerUrl,
+                    IsPage = item.IsPage,
+                    IsSkip = item.IsSkip,
+                    LabelName = item.LabelName,
+                    ResourceType = item.ResourceType,
+                    LabelNameDescribe = item.LabelNameDescribe,
+                    Remark = item.Remark
+                };
+                // 特殊 130,示范课堂140,品牌专区1(150),品牌专区2(160)
+                var specialInts = systemLabels.Where(n => n.ResourceType >= 130).Select(n => n.ResourceType);
+                if (specialInts.Contains(item.ResourceType))
+                {
+                    //获取特殊
+                    navigationLabelMediaResult.IsSpecial = true;
+                    navigationLabelMediaResult.SpecialLabelResults = await specialLabelRepository.GetAllAsync(item.ResourceType);
+                    foreach (var specialLabelResult in navigationLabelMediaResult.SpecialLabelResults)
+                        specialLabelResult.ImageUrls = StringUtils.AddDomain(specialLabelResult.ImageUrls);
+                    result.NavigationLabelMediaResults.Add(navigationLabelMediaResult);
+                    continue;
+                }
+                //获取媒体标签
+                var mediaIds = await _mediaLableRepository.GetMediaIdsAysnc(item.Id);
+                var medias = await _mediaRepository.GetNavigationMediaResults(mediaIds);
+                navigationLabelMediaResult.MediaResults = medias.ToList();
+                foreach (var itemMedia in navigationLabelMediaResult.MediaResults)
+                    itemMedia.ImageUrls = StringUtils.AddDomain(itemMedia.ImageUrls);
+                result.NavigationLabelMediaResults.Add(navigationLabelMediaResult);
+
+            }
+            return result;
+        }
     }
 }

+ 8 - 3
gx_api/GxPress/Service/GxPress.Service.Interface/Navigation/INavigationService.cs

@@ -3,12 +3,17 @@ using GxPress.Result.Navigation;
 
 namespace GxPress.Service.Interface.Navigation
 {
-    public interface INavigationService:IService
+    public interface INavigationService : IService
     {
-           /// <summary>
+        /// <summary>
         /// 获取导航栏数据
         /// </summary>
         /// <returns></returns>
-       Task<MiddleLableResult> GetNavigationResults(int navigationId);
+        Task<MiddleLableResult> GetNavigationResults(int navigationId);
+        /// <summary>
+        /// 获取中间页面数据
+        /// </summary>
+        /// <returns></returns>
+        Task<MiddleLableResult> GetMiddleLableResults(int middleLableId);
     }
 }