예제 #1
0
        public IActionResult Apoint(Team team)
        {
            var           groupService  = new GroupService();
            var           model         = groupService.GetGroupById(team.Gid);
            var           gracService   = new GracService();
            var           gracs         = gracService.GetAIdByGId(team.Gid);
            List <Author> accesslist    = new List <Author>();
            var           accessService = new AccessService();

            for (int i = 0; i < gracs.Count; i++)
            {
                var alist = accessService.GetAccessById(gracs[i].Aid.Value);
                accesslist.Add(alist);
            }
            ViewData["Authors"] = accesslist;


            var allAccessList = accessService.GetAll();
            var unAuthorList  = new List <Author>();

            foreach (var author in allAccessList)
            {
                var isAdd = !accesslist.Exists(x => x.Aid == author.Aid);
                if (isAdd)
                {
                    unAuthorList.Add(author);
                }
            }
            ViewData["UnAuthorList"] = unAuthorList;
            return(View(model));
        }
예제 #2
0
        /// <summary>
        /// 查看用户权限树
        /// </summary>
        /// <returns></returns>
        public IActionResult Show(User user, Team team, Role role)
        {
            //获取用户信息
            var userService    = new UserService();
            var model          = userService.GetUserById(user.Uid);
            var useraccService = new UserAccService();
            //获取用户权限点
            var           useraccs      = useraccService.GetAIdByUId(user.Uid);
            List <Author> accesslist    = new List <Author>();
            var           accessService = new AccessService();

            for (int i = 0; i < useraccs.Count; i++)
            {
                var alist = accessService.GetAccessById(useraccs[i].Aid.Value);
                accesslist.Add(alist);
            }
            //获取所属用户组
            //获取用户组所有权限点
            var         userteService = new UserTeService();
            var         usertes       = userteService.GetGIdByUId(user.Uid);
            List <Team> grouplist     = new List <Team>();
            var         groupService  = new GroupService();
            var         gracService   = new GracService();

            for (int i = 0; i < usertes.Count; i++)
            {
                var glist = groupService.GetGroupById(usertes[i].Gid.Value);
                grouplist.Add(glist);
                var gracs = gracService.GetAIdByGId(usertes[i].Gid.Value);
                for (int j = 0; j < gracs.Count; j++)
                {
                    var aglist = accessService.GetAccessById(gracs[j].Aid.Value);
                    accesslist.Add(aglist);
                }
            }

            //获取用户角色
            //获取角色权限点
            var         userroService  = new UserRoService();
            var         useros         = userroService.GetRIdByUId(user.Uid);
            List <Role> rolelist       = new List <Role>();
            var         roleService    = new RoleService();
            var         roleaccService = new RoleAccService();

            for (int i = 0; i < useros.Count; i++)
            {
                var rlist = roleService.GetRoleById(useros[i].Rid.Value);
                rolelist.Add(rlist);
                var roacs = roleaccService.GetAIdByRId(useros[i].Rid.Value);
                for (int j = 0; j < roacs.Count; j++)
                {
                    var arlist = accessService.GetAccessById(roacs[j].Aid.Value);
                    accesslist.Add(arlist);
                }
            }
            //List<Author> alllist = accesslist.Distinct().ToList();
            //查重
            var allList = new List <Author>();

            foreach (var author in accesslist)
            {
                var isAdd = !allList.Exists(x => x.Aid == author.Aid);
                if (isAdd)
                {
                    allList.Add(author);
                }
            }
            ViewData["Authors"] = allList;
            return(View(model));
        }