李昊 4 年之前
父節點
當前提交
901ccca3c9

+ 2 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/Category/CategoryRepository.cs

@@ -102,8 +102,7 @@ namespace GxPress.Repository.Implement.Category
             var result = new List<CategoryResult>();
             result.Add(new CategoryResult { Id = 0, Name = "推荐", IsDisable = false });
             var categoryResults = categoryAll.Where(n => n.ParentId == 0).Select(n => _mapper.Map<CategoryResult>(n)).ToList();
-            result.AddRange(categoryResults);
-            foreach (var item in result)
+            foreach (var item in categoryResults)
             {
                 item.IsChildren = categoryAll.Any(n => n.ParentId == item.Id);
                 item.Children = categoryAll.Where(n => n.ParentId == item.Id).Select(n => _mapper.Map<CategoryResult>(n)).ToList();
@@ -116,6 +115,7 @@ namespace GxPress.Repository.Implement.Category
                     }
                 }
             }
+            result.AddRange(categoryResults);
             return result;
         }
     }