Beispiel #1
0
        public BcUserInfoEntity GetBcUserInfoWithPermission(string userAccount)
        {
            var entity =
                EntityExecution.SelectOne <BcUserInfoEntity>(
                    n => n.UserAccount == userAccount && n.ActivityFlag == true && n.DeleteFlag == false);

            //获取用户的角色
            var userRoleList = new BcUserRoleBiz().GetBcUserRoleList(entity.UserId);

            entity.RoleList = new List <BcRoleEntity>();
            foreach (BcUserRoleEntity userRoleEntity in userRoleList)
            {
                entity.RoleList.Add(new BcRoleEntity()
                {
                    RoleId   = userRoleEntity.RoleId,
                    RoleName = userRoleEntity.RoleName
                });
            }

            //获取用户是否为超级管理员
            entity.IsSuperAdmin = new SysGlobalSettingBiz().IsSuperAdmin(entity.UserAccount);

            //获取用户的权限
            if (entity.IsSuperAdmin)
            {
                //如果是超级管理员,获取所有权限
                entity.PermisionList = new List <PermissionEntity>();
                var sysRelationList = new SysRelationBiz().GetEnabledSysRelationList();
                foreach (SysRelationEntity sysRelationEntity in sysRelationList)
                {
                    entity.PermisionList.Add(new PermissionEntity()
                    {
                        ModuleId       = sysRelationEntity.ModuleId,
                        FuncPointId    = sysRelationEntity.FuncPointId,
                        PermissionList = sysRelationEntity.PermissionList
                    });
                }
            }
            else
            {
                //如果不是超级管理员,获取用户权限和角色权限
                var bcPermissionBiz = new BcPermissionBiz();

                //1、获取用户权限
                entity.PermisionList = new List <PermissionEntity>();
                var bcUserPermissionList = bcPermissionBiz.GetEnabledBcPermissionList(2, entity.UserId);
                foreach (BcPermissionEntity bcPermissionEntity in bcUserPermissionList)
                {
                    entity.PermisionList.Add(new PermissionEntity()
                    {
                        ModuleId       = bcPermissionEntity.ModuleId,
                        FuncPointId    = bcPermissionEntity.FuncPointId,
                        PermissionList = bcPermissionEntity.Permissions.Split(',').ToList()
                    });
                }

                //2、获取角色权限
                foreach (BcRoleEntity bcRoleEntity in entity.RoleList)
                {
                    var bcRolePermissionList = bcPermissionBiz.GetEnabledBcPermissionList(1, bcRoleEntity.RoleId);
                    foreach (BcPermissionEntity bcPermissionEntity in bcRolePermissionList)
                    {
                        var list =
                            entity.PermisionList.Where(
                                n =>
                                n.ModuleId == bcPermissionEntity.ModuleId &&
                                n.FuncPointId == bcPermissionEntity.FuncPointId).ToList();
                        if (list.Count > 0)
                        {
                            var pcList = bcPermissionEntity.Permissions.Split(',').ToList();
                            foreach (string s in pcList)
                            {
                                if (!list[0].PermissionList.Contains(s))
                                {
                                    list[0].PermissionList.Add(s);
                                }
                            }
                        }
                        else
                        {
                            entity.PermisionList.Add(new PermissionEntity()
                            {
                                ModuleId       = bcPermissionEntity.ModuleId,
                                FuncPointId    = bcPermissionEntity.FuncPointId,
                                PermissionList = bcPermissionEntity.Permissions.Split(',').ToList()
                            });
                        }
                    }
                }
            }

            //根据用户权限,获取用户的菜单列表
            entity.MenuList = new SysMenuBiz().GetEnabledSysMenuListByPermission(entity.PermisionList);

            return(entity);
        }
Beispiel #2
0
        public BcUserInfoEntity GetBcUserInfoWithPermission(string userAccount)
        {
            var entity =
                EntityExecution.SelectOne<BcUserInfoEntity>(
                    n => n.UserAccount == userAccount && n.ActivityFlag == true && n.DeleteFlag == false);

            //获取用户的角色
            var userRoleList = new BcUserRoleBiz().GetBcUserRoleList(entity.UserId);
            entity.RoleList = new List<BcRoleEntity>();
            foreach (BcUserRoleEntity userRoleEntity in userRoleList)
            {
                entity.RoleList.Add(new BcRoleEntity()
                {
                    RoleId = userRoleEntity.RoleId,
                    RoleName = userRoleEntity.RoleName
                });
            }

            //获取用户是否为超级管理员
            entity.IsSuperAdmin = new SysGlobalSettingBiz().IsSuperAdmin(entity.UserAccount);

            //获取用户的权限
            if (entity.IsSuperAdmin)
            {
                //如果是超级管理员,获取所有权限
                entity.PermisionList = new List<PermissionEntity>();
                var sysRelationList = new SysRelationBiz().GetEnabledSysRelationList();
                foreach (SysRelationEntity sysRelationEntity in sysRelationList)
                {
                    entity.PermisionList.Add(new PermissionEntity()
                    {
                        ModuleId = sysRelationEntity.ModuleId,
                        FuncPointId = sysRelationEntity.FuncPointId,
                        PermissionList = sysRelationEntity.PermissionList
                    });
                }
            }
            else
            {
                //如果不是超级管理员,获取用户权限和角色权限
                var bcPermissionBiz = new BcPermissionBiz();

                //1、获取用户权限
                entity.PermisionList = new List<PermissionEntity>();
                var bcUserPermissionList = bcPermissionBiz.GetEnabledBcPermissionList(2, entity.UserId);
                foreach (BcPermissionEntity bcPermissionEntity in bcUserPermissionList)
                {
                    entity.PermisionList.Add(new PermissionEntity()
                    {
                        ModuleId = bcPermissionEntity.ModuleId,
                        FuncPointId = bcPermissionEntity.FuncPointId,
                        PermissionList = bcPermissionEntity.Permissions.Split(',').ToList()
                    });
                }

                //2、获取角色权限
                foreach (BcRoleEntity bcRoleEntity in entity.RoleList)
                {
                    var bcRolePermissionList = bcPermissionBiz.GetEnabledBcPermissionList(1, bcRoleEntity.RoleId);
                    foreach (BcPermissionEntity bcPermissionEntity in bcRolePermissionList)
                    {
                        var list =
                            entity.PermisionList.Where(
                                n =>
                                    n.ModuleId == bcPermissionEntity.ModuleId &&
                                    n.FuncPointId == bcPermissionEntity.FuncPointId).ToList();
                        if (list.Count > 0)
                        {
                            var pcList = bcPermissionEntity.Permissions.Split(',').ToList();
                            foreach (string s in pcList)
                            {
                                if (!list[0].PermissionList.Contains(s))
                                    list[0].PermissionList.Add(s);
                            }
                        }
                        else
                        {
                            entity.PermisionList.Add(new PermissionEntity()
                            {
                                ModuleId = bcPermissionEntity.ModuleId,
                                FuncPointId = bcPermissionEntity.FuncPointId,
                                PermissionList = bcPermissionEntity.Permissions.Split(',').ToList()
                            });
                        }
                    }
                }
            }

            //根据用户权限,获取用户的菜单列表
            entity.MenuList = new SysMenuBiz().GetEnabledSysMenuListByPermission(entity.PermisionList);

            return entity;
        }