2025-07-03 13:53:29 +08:00
|
|
|
using System.Diagnostics;
|
2025-07-15 22:18:37 +08:00
|
|
|
using AutoMapper;
|
2025-07-19 09:25:01 +08:00
|
|
|
using DMS.Core.Helper;
|
2025-07-21 18:49:49 +08:00
|
|
|
using DMS.Core.Interfaces.Repositories;
|
2025-07-19 09:25:01 +08:00
|
|
|
using DMS.Core.Models;
|
|
|
|
|
using DMS.Infrastructure.Data;
|
2025-07-21 18:49:49 +08:00
|
|
|
using DMS.Infrastructure.Entities;
|
2025-06-24 20:48:38 +08:00
|
|
|
|
2025-07-18 22:21:16 +08:00
|
|
|
namespace DMS.Infrastructure.Repositories;
|
2025-06-24 20:48:38 +08:00
|
|
|
|
2025-07-21 18:49:49 +08:00
|
|
|
public class MenuRepository : BaseRepository<DbMenu>, IMenuRepository
|
2025-06-24 20:48:38 +08:00
|
|
|
{
|
2025-07-21 18:49:49 +08:00
|
|
|
private readonly IMapper _mapper;
|
|
|
|
|
|
|
|
|
|
public MenuRepository(IMapper mapper, SqlSugarDbContext dbContext)
|
2025-07-19 14:36:34 +08:00
|
|
|
: base(dbContext)
|
2025-06-24 20:48:38 +08:00
|
|
|
{
|
2025-07-21 18:49:49 +08:00
|
|
|
_mapper = mapper;
|
2025-06-24 20:48:38 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-21 18:49:49 +08:00
|
|
|
|
|
|
|
|
public async Task<List<MenuBean>> GetMenuTreesAsync()
|
2025-06-24 20:48:38 +08:00
|
|
|
{
|
2025-07-21 18:49:49 +08:00
|
|
|
var stopwatch = new Stopwatch();
|
2025-07-03 13:53:29 +08:00
|
|
|
stopwatch.Start();
|
2025-07-19 11:11:01 +08:00
|
|
|
var dbMenuTree = await Db.Queryable<DbMenu>()
|
2025-07-21 14:35:17 +08:00
|
|
|
.ToTreeAsync(dm => dm.Childrens, dm => dm.ParentId, 0);
|
2025-07-19 11:11:01 +08:00
|
|
|
stopwatch.Stop();
|
|
|
|
|
NlogHelper.Info($"获取菜单树耗时:{stopwatch.ElapsedMilliseconds}ms");
|
2025-07-21 18:49:49 +08:00
|
|
|
return _mapper.Map<List<MenuBean>>(dbMenuTree);
|
2025-06-24 20:48:38 +08:00
|
|
|
}
|
2025-06-26 19:36:27 +08:00
|
|
|
|
2025-06-30 22:03:49 +08:00
|
|
|
|
2025-07-21 18:49:49 +08:00
|
|
|
public async Task<MenuBean> GetByIdAsync(int id) => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public async Task<List<MenuBean>> GetAllAsync() => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public async Task<MenuBean> AddAsync(MenuBean entity) => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public async Task<int> UpdateAsync(MenuBean entity) => throw new NotImplementedException();
|
2025-07-05 21:49:41 +08:00
|
|
|
|
2025-07-21 18:49:49 +08:00
|
|
|
public async Task<int> DeleteAsync(MenuBean entity) => throw new NotImplementedException();
|
2025-06-30 20:11:21 +08:00
|
|
|
}
|