예제 #1
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);
        }