Example #1
0
        public JsonResult ChangeAuthRoleNodeButton()
        {
            if (!Utits.IsLogin)
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 3;
                sRetrunModel.MessageContent = "用户登录过期,请重新登录后操作.";
                return(Json(sRetrunModel));
            }
            #region 设置角色节点按钮权限
            #region 参数判断
            Guid   roleId  = new Guid(Request["roleId"]);
            string menuIds = Request["menuIds"];

            List <string> menuIdlist = new List <string>();
            if (!string.IsNullOrEmpty(menuIds))
            {
                menuIdlist = menuIds.Split(',').ToList();
            }

            #endregion
            var  authRoleNodeButtonBll = new AuthRoleNodeButtonBll();
            bool isFlag = authRoleNodeButtonBll.UpdateAuthRoleNodeButton(menuIdlist, roleId);
            if (isFlag)
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 1;
                sRetrunModel.MessageContent = "操作成功.";
                return(Json(sRetrunModel));
            }
            else
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 0;
                sRetrunModel.MessageContent = "操作失败.";
                return(Json(sRetrunModel));
            }
            #endregion
        }
Example #2
0
        public JsonResult TreeAuthRoleNodeButton()
        {
            var           nodesBll = new NodesBll();
            IList <Nodes> list     = nodesBll.SearchListByValid(Utits.IsSuper);

            if (list != null)
            {
                list = list.OrderBy(c => c.OrderIndex).ToList();
            }
            else
            {
                list = new List <Nodes>();
            }

            IList <AuthRoleNodeButton> mtrList = null;
            Guid roleId = RequestParameters.PGuid("RoleID");

            if (roleId != Guid.Empty)
            {
                var authUserNodeBll = new AuthRoleNodeButtonBll();
                mtrList = authUserNodeBll.GetListByRoleId(roleId);//该角色拥有的节点按钮权限
            }
            if (mtrList == null)
            {
                mtrList = new List <AuthRoleNodeButton>();
            }
            var                 listTree = new List <TreeModel>();
            TreeModel           itemTree;
            var                 nodeToButtonBll   = new NodeButtonBll();
            var                 listvNodeToButton = nodeToButtonBll.SearchByValid(Utits.IsSuper);
            IList <vNodeButton> listNodeToButton;
            TreeModel           itemNode;
            AuthRoleNodeButton  itemAuthRoleNodeButton;

            foreach (Nodes item in list)
            {
                itemTree          = new TreeModel();
                itemTree.Id       = item.NodeId;
                itemTree.Name     = item.NodeName;
                itemTree.Pid      = item.ParentID;
                itemTree.nocheck  = true;
                itemTree.Checkbox = !itemTree.nocheck;
                itemTree.open     = true;
                listTree.Add(itemTree);


                if (item.NodeType != -1)//表示非系统页面(节点)
                {
                    listNodeToButton = listvNodeToButton.Where(c => c.NodeId == item.NodeId).ToList();
                    foreach (var itemNtb in listNodeToButton)
                    {
                        itemNode               = new TreeModel();
                        itemNode.Id            = itemNtb.NodeButtonId + 100000;
                        itemNode.Name          = itemNtb.BtnName;
                        itemNode.Pid           = item.NodeId;
                        itemAuthRoleNodeButton = mtrList.FirstOrDefault(c => c.NodeButtonId == itemNtb.NodeButtonId);
                        if (itemAuthRoleNodeButton != null)
                        {
                            itemNode.Checked = true;
                        }
                        itemNode.nocheck  = false;
                        itemNode.Checkbox = !itemNode.nocheck;
                        itemTree.open     = true;
                        listTree.Add(itemNode);
                    }
                }
            }

            return(Json(listTree));
        }