|
|
@@ -226,6 +226,50 @@ namespace BPA.SAAS.Manage.Application.System.Services |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 动态菜单(菜单树) |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree() |
|
|
|
{ |
|
|
|
var UserId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; |
|
|
|
var IsAdmin = App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value; |
|
|
|
var account = App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; |
|
|
|
|
|
|
|
if (UserId == null) |
|
|
|
return null; |
|
|
|
List<BPA_Menu> AllMenus = new List<BPA_Menu>(); |
|
|
|
if (IsAdmin == "1" && account == "admin") |
|
|
|
AllMenus =await _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0 && t.Status == 0).OrderBy(t => t.Sort).ToListAsync(); |
|
|
|
else |
|
|
|
AllMenus =await _db.Queryable<BPA_Menu>().LeftJoin<BPA_RoleMenu>((t, x) => t.Id == x.SysMenuId).LeftJoin<BPA_UserRole>((t, x, y) => x.SysRoleId == y.SysRoleId) |
|
|
|
.Where((t, x, y) => y.SysUserId == UserId && t.Status == 0).Select(t => t).ToListAsync(); |
|
|
|
//菜单去重 |
|
|
|
AllMenus = AllMenus.Where((x, i) => AllMenus.FindIndex(z => z.Id == x.Id) == i).ToList(); |
|
|
|
var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").OrderBy(t => t.Sort).Select(t => new MenuRouteDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = t.Component, |
|
|
|
Icon = t.Icon, |
|
|
|
Name = t.Name, |
|
|
|
Path = t.Router, |
|
|
|
Routes = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = x.Component, |
|
|
|
Name = x.Name, |
|
|
|
Path = x.Router, |
|
|
|
Routes = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuRouteChildDtoOutput |
|
|
|
{ |
|
|
|
Id = t.Id, |
|
|
|
Component = y.Component, |
|
|
|
Name = y.Name, |
|
|
|
Path = y.Router |
|
|
|
}).ToList() |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
return data; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 启用 |
|
|
|
/// </summary> |
|
|
|
/// <param name="Id"></param> |
|
|
|