| | |
| | | using FlexJobApi.Core; |
| | | using Furion.DatabaseAccessor; |
| | | using Mapster; |
| | | using MediatR; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | |
| | | namespace FlexJobApi.User.Application |
| | | { |
| | | //public class MenuAllQueryHandler:IRequestHandler<MenuAllQuery, > |
| | | //{ |
| | | //} |
| | | /// <summary> |
| | | /// 查询所有菜单 |
| | | /// </summary> |
| | | public class MenuAllQueryHandler( |
| | | IRepository<Menu> menuRep) |
| | | : IRequestHandler<MenuAllQuery, MenuAllCallback> |
| | | { |
| | | private readonly IRepository<Menu> menuRep = menuRep; |
| | | |
| | | /// <inheritdoc/> |
| | | public async Task<MenuAllCallback> Handle(MenuAllQuery request, CancellationToken cancellationToken) |
| | | { |
| | | var config = new TypeAdapterConfig(); |
| | | config.Default.MaxDepth(10); |
| | | var callback = new MenuAllCallback(); |
| | | callback.Items = await menuRep.AsQueryable() |
| | | .Include(it => it.Childrens.Where(c => |
| | | c.Type == EnumMenuType.Menu |
| | | || c.Type == EnumMenuType.Page |
| | | || c.Type == EnumMenuType.Modal)) |
| | | .OrderBy(it => it.Sort).ThenBy(it => it.CreatedTime) |
| | | .Where(it => |
| | | it.Type == EnumMenuType.Menu |
| | | || it.Type == EnumMenuType.Page |
| | | || it.Type == EnumMenuType.Modal) |
| | | .ProjectToType<MenuAllCallbackItem>(config) |
| | | .ToListAsync(cancellationToken); |
| | | return callback; |
| | | } |
| | | } |
| | | } |