public async Task <ListResp <GetRoleItemResp> > GetAuthUserFuncList()
        {
            var memIdentityRes = await AdminHelper.GetAuthAdmin();

            if (!memIdentityRes.IsSuccess())
            {
                return(new ListResp <GetRoleItemResp>().WithResp(memIdentityRes));
            }

            // 如果是超级管理员直接返回所有
            if (memIdentityRes.data.auth_type != PortalAuthorizeType.SuperAdmin)
            {
                return(await FuncHelper.GetAuthUserRoleFuncList());
            }

            var sysFunItemsRes = await FuncHelper.GetAllFuncItems();

            if (!sysFunItemsRes.IsSuccess())
            {
                return(new ListResp <GetRoleItemResp>().WithResp(sysFunItemsRes));
            }

            var roleItems = sysFunItemsRes.data.Select(item => item.ToRoleItemResp()).ToList();

            return(new ListResp <GetRoleItemResp>(roleItems));
        }
Beispiel #2
0
        private async Task <ListResp <RoleFunSmallMo> > GetUserAllFuncsNoCache()
        {
            var userIdentity = CoreUserContext.Identity;

            if (userIdentity.auth_type == PortalAuthorizeType.SuperAdmin)
            {
                // 如果是超级管理员直接返回所有
                var sysFunItemsRes = await FuncHelper.GetAllFuncItems();

                if (!sysFunItemsRes.IsSuccess())
                {
                    return(new ListResp <RoleFunSmallMo>().WithResp(sysFunItemsRes));
                }

                var roleItems = sysFunItemsRes.data.Select(item => item.ToSmallMo()).ToList();
                return(new ListResp <RoleFunSmallMo>(roleItems));
            }

            var userId     = userIdentity.id.ToInt64();
            var roleIdsRes = await GetUserRoles(userId);

            if (!roleIdsRes.IsSuccess())
            {
                return(new ListResp <RoleFunSmallMo>().WithResp(roleIdsRes));
            }

            var funcRes = await RoleFuncRep.Instance.GetRoleFuncList(roleIdsRes.data.Select(s => s.id).ToList());

            if (!funcRes.IsSuccess())
            {
                return(new ListResp <RoleFunSmallMo>().WithResp(funcRes, "未获取有效角色对应权限信息!"));
            }

            var funcItems = funcRes.data;
            var dir       = new Dictionary <string, RoleFunSmallMo>();

            foreach (var f in funcItems)
            {
                if (!dir.ContainsKey(f.func_code))
                {
                    dir.Add(f.func_code, f);
                    continue;
                }

                var fValue = dir[f.func_code];
                if (f.data_level < fValue.data_level)
                {
                    fValue.data_level = f.data_level;
                }
            }

            return(new ListResp <RoleFunSmallMo>(dir.Select(d => d.Value).ToList()));
        }
Beispiel #3
0
 /// <summary>
 ///  获取系统所有权限项
 /// </summary>
 /// <returns></returns>
 public Task <ListResp <FuncBigItem> > GetAllFuncItems()
 {
     return(FuncHelper.GetAllFuncItems());
 }