/// <summary> /// /// </summary> public void OnGet(Guid id) { Role = _sysRoleService.GetRoleMapping(id); var categories = _sysCategoryService.GetAllCache(); Sys_Categories = categories.Where(o => o.Target == "0").ToList(); Permissions = _sysRoleService.GetRolePermissons().Where(o => o.RoleId == id).ToList(); }
public IActionResult RolePrm(string id) { var role = _sysRoleService.GetRoleMapping(id); var categories = _sysCategoryService.GetAllCache(); ViewBag.Categories = categories.Where(o => o.target == "0").ToList(); role.SysPermissions = _sysRoleService.GetRolePermissons().Where(o => o.role_id == id).ToList(); return(PartialView(role)); }
/// <summary> /// 获取我的权限 /// </summary> /// <param name="plaftorm"></param> /// <returns></returns> public List <Sys_CategoryMapping> GetMyCategories(int plaftorm = 0) { var data = _httpContextAccessor.HttpContext.Items[ITEMS_CATEGORYIES_KEY] as List <Sys_CategoryMapping>; if (data == null) { var user = GetUserData(plaftorm); var categories = _sysCategoryService.GetAllCache().Where(o => o.Target == plaftorm.ToString()).ToList(); if (user.IsAdmin) { return(categories); } var userPermissions = _sysRoleService.GetUserPermissions(user.Id); if (userPermissions != null) { data = userPermissions.Join(categories, up => up.CategoryId, c => c.Id, (a, b) => b).Distinct().ToList(); if (data != null) { _httpContextAccessor.HttpContext.Items[ITEMS_CATEGORYIES_KEY] = data; } } } return(data); }