Procházet zdrojové kódy

菜单树结构查询调整

storemanagement
zhaoy před 8 měsíci
rodič
revize
efd12be8e6
5 změnil soubory, kde provedl 107 přidání a 3 odebrání
  1. +54
    -0
      BPA.SAAS.Manage.Application/System/Dtos/MenuRouteDtoOutput.cs
  2. +1
    -0
      BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
  3. +7
    -2
      BPA.SAAS.Manage.Application/System/MenuServices.cs
  4. +44
    -0
      BPA.SAAS.Manage.Application/System/Services/MenuService.cs
  5. +1
    -1
      BPA.SAAS.Manage.Web.Entry/BPA.SAAS.Manage.Web.Entry.csproj.user

+ 54
- 0
BPA.SAAS.Manage.Application/System/Dtos/MenuRouteDtoOutput.cs Zobrazit soubor

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.System.Dtos
{
public class MenuRouteDtoOutput
{

public string Id { get; set; }
/// <summary>
/// 组件
/// </summary>
public string Component { get; set; }
/// <summary>
/// 路劲
/// </summary>
public string Path { get; set; }
/// <summary>
/// 图标
/// </summary>
public string Icon { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 路由
/// </summary>
public List<MenuRouteChildDtoOutput> Routes { get; set; }
}
public class MenuRouteChildDtoOutput
{
public string Id { get; set; }
/// <summary>
/// 组件
/// </summary>
public string Component { get; set; }
/// <summary>
/// 路劲
/// </summary>
public string Path { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 路由
/// </summary>
public List<MenuRouteChildDtoOutput> Routes { get; set; }
}
}

+ 1
- 0
BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs Zobrazit soubor

@@ -14,6 +14,7 @@ namespace BPA.SAAS.Manage.Application.System.Interface
Task<bool> Update(MenuDtoInput input);
Task<bool> Delete(List<string> input);
Task<List<MenuTreeOutput>> MenuTree(string getType);
Task<List<MenuRouteDtoOutput>> DymicMenuTree();
Task<bool> Enable(string Id);
Task<bool> Disable(string Id);
}


+ 7
- 2
BPA.SAAS.Manage.Application/System/MenuServices.cs Zobrazit soubor

@@ -54,13 +54,18 @@ namespace BPA.SAAS.Manage.Application.System
/// <summary>
/// 查询菜单树
/// </summary>
/// <param name="GetType"></param>
/// <param name="getType"></param>
/// <returns></returns>
[HttpGet("/api/menu/menutree")]
[HttpGet("/api/menu/menutrees")]
public async Task<List<MenuTreeOutput>> MenuTree(string getType)
{
return await _menuService.MenuTree(getType);
}
[HttpGet("/api/menu/menutree")]
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree()
{
return await _menuService.DymicMenuTree();
}
[HttpGet("/api/menu/enable")]
public async Task<bool> Enable(string Id)
{


+ 44
- 0
BPA.SAAS.Manage.Application/System/Services/MenuService.cs Zobrazit soubor

@@ -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>


+ 1
- 1
BPA.SAAS.Manage.Web.Entry/BPA.SAAS.Manage.Web.Entry.csproj.user Zobrazit soubor

@@ -4,6 +4,6 @@
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
<ActiveDebugProfile>BPA.SAAS.Manage.Web.Entry</ActiveDebugProfile>
</PropertyGroup>
</Project>

Načítá se…
Zrušit
Uložit