|
@@ -6,7 +6,7 @@ using GxPress.Common.AppOptions;
|
|
|
using GxPress.Common.Tools;
|
|
|
using GxPress.Repository.Interface.Menus;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
-
|
|
|
+using System.Linq;
|
|
|
namespace GxPress.Repository.Implement.Menus
|
|
|
{
|
|
|
public class MenusRepository : IMenusRepository
|
|
@@ -44,12 +44,26 @@ namespace GxPress.Repository.Implement.Menus
|
|
|
|
|
|
public async Task<IEnumerable<Entity.Menus.Menus>> GetAllAsync()
|
|
|
{
|
|
|
- return await _repository.GetAllAsync();
|
|
|
+ var all = await _repository.GetAllAsync();
|
|
|
+ var list = new List<Entity.Menus.Menus>();
|
|
|
+ list = all.Where(n => n.ParentId == 0).ToList();
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ item.Children = all.Where(n => n.ParentId == item.Id).ToList();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
- public async Task<IEnumerable<Entity.Menus.Menus>> GetAllAsync(List<int> menusIds)
|
|
|
+ public async Task<IEnumerable<Entity.Menus.Menus>> GetAllAsync(List<int> menusIds)
|
|
|
{
|
|
|
- return await _repository.GetAllAsync(Q.WhereIn(nameof(Entity.Menus.Menus.Id),menusIds));
|
|
|
+ var all = await _repository.GetAllAsync(Q.WhereIn(nameof(Entity.Menus.Menus.Id), menusIds));
|
|
|
+ var list = new List<Entity.Menus.Menus>();
|
|
|
+ list = all.Where(n => n.ParentId == 0).ToList();
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ item.Children = all.Where(n => n.ParentId == item.Id).ToList();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|
|
|
}
|