Exemplo n.º 1
0
 public void ModifyRolePower(RolePower request, RolePowerResponse response)
 {
     ValidRequest(request, new RolePowerVaildator(), ruleSet: "Modify");
     _roleRepository.DeleteAllRolePower(request.RoleNo);
     _roleRepository.InsertRoleMenus(request.RoleNo, request.Menus);
     _roleRepository.InsertRoleHandles(request.RoleNo, request.Handles);
     _roleRepository.InsertRoleMenuFather(request.RoleNo);
     response.ResponseStatus.ErrorCode = "OK";
 }
Exemplo n.º 2
0
        public void QueryRolePowerHandle(RolePower request, RolePowerResponse response)
        {
            ValidRequest(request, new RolePowerVaildator(), ruleSet: "Query");
            var list = _roleRepository.QueryRolePowerHandle(request.RoleNo);

            response.QueryData = new Report {
                total = list.Count, rows = list
            };
            response.ResponseStatus.ErrorCode = "OK";
        }
Exemplo n.º 3
0
        public void QueryRolePowerMenus(RolePower request, RolePowerResponse response)
        {
            var            menuPris    = _roleRepository.QueryRolePowerMenus(request.RoleNo).ToList();
            List <MenuPri> menuPristmp = new List <MenuPri>();

            foreach (var tmp in menuPris)
            {
                tmp.attributes = new Attributes
                {
                    Pid = tmp.Pid
                };
                menuPristmp.Add(tmp);
            }
            //构造菜单
            Func <MenuPri, IEnumerable <MenuPri>, MenuPriView> getMenuPriTree = null;

            getMenuPriTree = (menu, source) =>
            {
                MenuPriView    view       = new MenuPriView(menu);
                var            enumerable = source as MenuPri[] ?? source.ToArray();
                List <MenuPri> children   = enumerable.Where(m => m.attributes.Pid == menu.id).OrderBy(m => m.id).ToList();
                foreach (MenuPri child in children)
                {
                    MenuPriView childView = getMenuPriTree(child, enumerable);
                    view.children.Add(childView);
                }
                return(view);
            };
            List <MenuPri>     roots = menuPristmp.Where(m => m.attributes.Pid == "000000").OrderBy(m => m.id).ToList();
            List <MenuPriView> datas = (from root in roots
                                        let source = menuPristmp.Where(m => m.attributes.Pid.Equals(root.id)).ToList()
                                                     select getMenuPriTree(root, source)).ToList();

            MenuPriView mp = new MenuPriView(new MenuPri {
                id = "000000", text = "页面根目录", state = "open"
            })
            {
                children = datas
            };
            List <MenuPriView> datatmp = new List <MenuPriView> {
                mp
            };

            response.Menus = datatmp;
            response.ResponseStatus.ErrorCode = "OK";
        }
Exemplo n.º 4
0
        public object Post(RolePower request)
        {
            RolePowerResponse rsp = new RolePowerResponse();

            if (request.RequestType == (short)RolePowerRequestType.Menu)
            {
                _privilegeService.QueryRolePowerMenus(request, rsp);
            }
            else if (request.RequestType == (short)RolePowerRequestType.Handle)
            {
                _privilegeService.QueryRolePowerHandle(request, rsp);
            }
            else if (request.RequestType == (short)RolePowerRequestType.Modify)
            {
                _privilegeService.ModifyRolePower(request, rsp);
            }
            return(rsp);
        }