using System.Diagnostics; using AutoMapper; using DMS.Core.Helper; using DMS.Core.Interfaces.Repositories; using DMS.Core.Models; using DMS.Infrastructure.Data; using DMS.Infrastructure.Entities; namespace DMS.Infrastructure.Repositories; public class MenuRepository : BaseRepository, IMenuRepository { private readonly IMapper _mapper; public MenuRepository(IMapper mapper, SqlSugarDbContext dbContext) : base(dbContext) { _mapper = mapper; } public async Task> GetMenuTreesAsync() { var stopwatch = new Stopwatch(); stopwatch.Start(); var dbMenuTree = await Db.Queryable() .ToTreeAsync(dm => dm.Childrens, dm => dm.ParentId, 0); stopwatch.Stop(); NlogHelper.Info($"获取菜单树耗时:{stopwatch.ElapsedMilliseconds}ms"); return _mapper.Map>(dbMenuTree); } public async Task GetByIdAsync(int id) => throw new NotImplementedException(); public async Task> GetAllAsync() => throw new NotImplementedException(); public async Task AddAsync(MenuBean entity) => throw new NotImplementedException(); public async Task UpdateAsync(MenuBean entity) => throw new NotImplementedException(); public async Task DeleteAsync(MenuBean entity) => throw new NotImplementedException(); }