示例#1
0
        /// <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();
        }
示例#2
0
        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));
        }
示例#3
0
        /// <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);
        }