| | |
| | | using FlexJobApi.Core; |
| | | using FlexJobApi.Core.Models; |
| | | using Furion.DatabaseAccessor; |
| | | using Mapster; |
| | | using MediatR; |
| | |
| | | public async Task<List<GetMenusQueryResultItem>> Handle(GetMenusQuery request, CancellationToken cancellationToken) |
| | | { |
| | | var q = rep.AsQueryable().AsNoTracking() |
| | | .OrderBy(it => it.Sort).ThenBy(it => it.CreatedTime) |
| | | .Where(it => it.UserType == request.UserType && it.ClientType == request.ClientType) |
| | | .Where(it => it.Type == EnumMenuType.Menu || it.Type == EnumMenuType.Page || it.Type == EnumMenuType.Modal); |
| | | var all = await q.ProjectToType<GetMenusQueryResultItem>().ToListAsync(); |
| | |
| | | foreach (var item in models) |
| | | { |
| | | item.IsChecked = roleMenuIds.Contains(item.Id); |
| | | item.Childrens = all.Where(it => it.ParentId == item.Id).ToList(); |
| | | if (item.Childrens.IsNotNull()) |
| | | item.Children = all.Where(it => it.ParentId == item.Id).ToList(); |
| | | if (item.Children.IsNotNull()) |
| | | { |
| | | LoopChildrens(item.Childrens, all, roleMenuIds); |
| | | LoopChildrens(item.Children, all, roleMenuIds); |
| | | } |
| | | } |
| | | } |