李昊 4 년 전
부모
커밋
690b8753e2

+ 4 - 4
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminNavigationController.cs

@@ -24,13 +24,13 @@ namespace GxPress.Api.AdminControllers
 
 
         /// <summary>
-        /// 列表
+        /// 列表 pc 1 移动 2
         /// </summary>
         /// <returns></returns>
-        [HttpGet]
-        public async Task<IEnumerable<Entity.Navigations.Navigation>> GetList()
+        [HttpGet("terminal")]
+        public async Task<IEnumerable<Entity.Navigations.Navigation>> GetList(int terminal)
         {
-            return await navigationRepository.GetAllAsync();
+            return await navigationRepository.GetAllAsync(terminal);
         }
         /// <summary>
         /// 添加导航

+ 12 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/Navigation/NavigationRepository.cs

@@ -53,10 +53,19 @@ namespace GxPress.Repository.Implement.Navigation
         {
             return await _repository.UpdateAsync(query) > 0;
         }
-
-        public async Task<IEnumerable<Entity.Navigations.Navigation>> GetAllAsync()
+        /// <summary>
+        /// 获取 pc 或者移动端
+        /// </summary>
+        /// <param name="terminal"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<Entity.Navigations.Navigation>> GetAllAsync(int terminal)
         {
-            return await _repository.GetAllAsync(Q.Where(nameof(Entity.Navigations.Navigation.IsDisable), false).OrderByDesc(nameof(Entity.Navigations.Navigation.Sort)));
+            var query = Q.NewQuery();
+            if (terminal > 0)
+                query.Where(nameof(Entity.Navigations.Navigation.Terminal), terminal);
+            query.Where(nameof(Entity.Navigations.Navigation.IsDisable), false);
+            query.OrderByDesc(nameof(Entity.Navigations.Navigation.Sort));
+            return await _repository.GetAllAsync(query);
         }
     }
 }

+ 1 - 1
gx_api/GxPress/Repository/GxPress.Repository.Interface/Navigation/INavigationRepository.cs

@@ -15,6 +15,6 @@ namespace GxPress.Repository.Interface.Navigation
         Task<bool> UpdateAsync(Entity.Navigations.Navigation note);
         Task<bool> UpdateAsync(SqlKata.Query query);
 
-        Task<IEnumerable<Entity.Navigations.Navigation>> GetAllAsync();
+        Task<IEnumerable<Entity.Navigations.Navigation>> GetAllAsync(int terminal);
     }
 }