Browse Source

菜单信息

master
Yanko 3 weeks ago
parent
commit
63e71a3ae3
5 changed files with 74 additions and 21 deletions
  1. +21
    -1
      backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
  2. +12
    -5
      backend/BPA.MES.Base.Application/Entitys/Sys/ModuleEntity.cs
  3. +14
    -2
      backend/BPA.MES.Base.Application/Services/SystemService/Dtos/UserRoleCacheDto.cs
  4. +19
    -9
      backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs
  5. +8
    -4
      backend/BPA.MES.Base.Core/TreeExtensions.cs

+ 21
- 1
backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml View File

@@ -1689,6 +1689,21 @@
状态
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.ModuleEntity.Path">
<summary>
路由地址
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.ModuleEntity.Component">
<summary>
文件地址
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.ModuleEntity.Sort">
<summary>
排序
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.RoleEntity">
<summary>
名 称 :角色信息
@@ -11034,7 +11049,7 @@
菜单图标
</summary>
</member>
<member name="P:BPA.MES.Base.Application.UserMenu.Children">
<member name="P:BPA.MES.Base.Application.UserMenu.Routes">
<summary>
菜单子项
</summary>
@@ -11059,6 +11074,11 @@
类别
</summary>
</member>
<member name="P:BPA.MES.Base.Application.UserMenu.Component">
<summary>
地址
</summary>
</member>
<member name="T:BPA.MES.Base.Application.AuthorizeService">
<summary>
名 称 :授权服务


+ 12
- 5
backend/BPA.MES.Base.Application/Entitys/Sys/ModuleEntity.cs View File

@@ -13,27 +13,22 @@
/// 类别 1:菜单,2:视图,3:功能
/// </summary>
public int Category { get; set; }

/// <summary>
/// 菜单打开方式 0:框架内嵌,1:新开页面
/// </summary>
public int OpenType { get; set; }

/// <summary>
/// 父级编号
/// </summary>
public string ParentId { get; set; }

/// <summary>
/// 名称
/// </summary>
public string Name { set; get; }

/// <summary>
/// 图标
/// </summary>
public string Icon { set; get; }

/// <summary>
/// 地址
/// </summary>
@@ -42,5 +37,17 @@
/// 状态
/// </summary>
public bool IsDisabled { get; set; }
/// <summary>
/// 路由地址
/// </summary>
public string Path { get; set; }
/// <summary>
/// 文件地址
/// </summary>
public string Component { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
}
}

+ 14
- 2
backend/BPA.MES.Base.Application/Services/SystemService/Dtos/UserRoleCacheDto.cs View File

@@ -33,15 +33,22 @@ public class UserMenu : ITree<UserMenu>
/// <summary>
/// 菜单地址
/// </summary>
public string Url { get; set; }
public string Url { get; set; }
public string Path { get {
return Url;
} }
/// <summary>
/// 菜单图标
/// </summary>
public string Icon { get; set; }
///// <summary>
///// 菜单子项
///// </summary>
//public List<UserMenu> Children { get; set; }
/// <summary>
/// 菜单子项
/// </summary>
public List<UserMenu> Children { get; set; }
public List<UserMenu> Routes { get; set; }
/// <summary>
/// 父级Id
/// </summary>
@@ -58,5 +65,10 @@ public class UserMenu : ITree<UserMenu>
/// 类别
/// </summary>
public int Category { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Component { get; set; }
}
}

+ 19
- 9
backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs View File

@@ -108,19 +108,30 @@

string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
string roleId = App.User?.FindFirst(ClaimConst.CLAINM_ROLEID)?.Value;
var result = new UserRoleCacheDto();
//根据角色获取权限Id
var rolemodules = await db.Queryable<RoleModuleEntity>().Where(x => x.RoleId == roleId).ToListAsync();
result.AuthorizationCodes = rolemodules.Select(t => t.ModuleId).ToList();
if (result.AuthorizationCodes.HasVal())
var employeeEntity = await db.Queryable<EmployeeEntity>().FirstAsync(x => x.RoleId==roleId);
if (employeeEntity.IsAdmin)
{
var temp = await db.Queryable<ModuleEntity>().Where(t => result.AuthorizationCodes.Contains(t.Id) && !t.IsDisabled).OrderBy(t => t.ParentId)
.ToListAsync();

var temp = await db.Queryable<ModuleEntity>().Where(t =>t.Category!=3 && !t.IsDisabled).OrderBy(t => t.ParentId)
.ToListAsync();
result.Menus = temp.Adapt<List<UserMenu>>().BuildTree();
}
result.Menus ??= new List<UserMenu>();
else
{
var roleModuleEntities = await db.Queryable<RoleModuleEntity>().Where(x => x.RoleId == roleId).ToListAsync();
result.AuthorizationCodes = roleModuleEntities.Select(t => t.ModuleId).ToList();
if (result.AuthorizationCodes.HasVal())
{
var temp = await db.Queryable<ModuleEntity>().Where(t => result.AuthorizationCodes.Contains(t.Id) && !t.IsDisabled).OrderBy(t => t.ParentId)
.ToListAsync();

result.Menus = temp.Adapt<List<UserMenu>>().BuildTree();
}
}
result.Menus ??= new List<UserMenu>();
result.Menus = result.Menus.OrderBy(t => t.Sort).ToList();
return result;
}
/// <summary>
@@ -255,8 +266,7 @@

var datas = await db.Queryable<ModuleEntity>()
.WhereIF(!string.IsNullOrEmpty(input.Name), t => t.Name.Contains(input.Name))
.OrderBy(it => it.ParentId)
.OrderBy(it => it.Name)
.OrderBy(it => it.Sort)
.ToListAsync();

var modules = datas.Adapt<List<ModuleTreeOutput>>();


+ 8
- 4
backend/BPA.MES.Base.Core/TreeExtensions.cs View File

@@ -25,7 +25,8 @@ namespace BPA.MES.Base.Core
resul = new List<T>();
list3.ForEach(delegate (T it)
{
it.Children = list2.BuildTree(it.Id);
//it.Children = list2.BuildTree(it.Id);
it.Routes = list2.BuildTree(it.Id);
resul.Add(it);
});
}
@@ -39,7 +40,9 @@ namespace BPA.MES.Base.Core

string ParentId { get; set; }

List<T> Children { get; set; }
//List<T> Children { get; set; }

List<T> Routes { get; set; }
}
public static List<T> DeleteTreeNodes<T>(this List<T> list, Func<T, bool> condition) where T : class, ITree<T>
{
@@ -52,9 +55,10 @@ namespace BPA.MES.Base.Core
{
list.Remove(val);
}
else if (val.Children.HasVal())
else if (val.Routes.HasVal())
{
val.Children.DeleteTreeNodes(condition);
//val.Children.DeleteTreeNodes(condition);
val.Routes.DeleteTreeNodes(condition);
}
}
}


Loading…
Cancel
Save