@@ -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> | |||
名 称 :授权服务 | |||
@@ -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; } | |||
} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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>>(); | |||
@@ -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); | |||
} | |||
} | |||
} | |||