public async Task <MessageModel <MenuInfo> > GetMenuInfoById(int mid)
        {
            var data = new MessageModel <MenuInfo>();

            if (mid == 0)
            {
                data.success = false;
                data.msg     = "获取菜单数据失败!";
                return(data);
            }
            var menuinfo = await menuService.QueryById(mid);

            if (menuinfo.mPid == 0)
            {
                menuinfo.arrPid = new List <int>()
                {
                    0
                };
            }
            else
            {
                var cmenuinfo = await menuService.QueryById(menuinfo.mPid);

                if (cmenuinfo.mPid == 0)
                {
                    menuinfo.arrPid = new List <int>()
                    {
                        0, menuinfo.mPid
                    };
                }
                else
                {
                    var ccmenuinfo = await menuService.QueryById(cmenuinfo.mPid);

                    menuinfo.arrPid = new List <int>()
                    {
                        0, ccmenuinfo.mID, menuinfo.mPid
                    };
                }
            }
            data.success = menuinfo.mID > 0;
            if (data.success)
            {
                data.msg      = "获取菜单数据成功!";
                data.response = menuinfo;
            }
            return(data);
        }
        public async Task <MessageModel <string> > SetRoleMenuList(RoleMenuInfo roleMenuInfo)
        {
            var data = new MessageModel <string>();

            if (roleMenuInfo.rID == 0 || string.IsNullOrEmpty(roleMenuInfo.mIDs))
            {
                data.success = false;
                data.msg     = "分配权限失败!";
                return(data);
            }
            try
            {
                unitOfWork.BeginTran();
                var rmids = (await roleMenuInfoService.Query(n => n.rID == roleMenuInfo.rID)).Select(n => n.rmID.ToString()).ToArray();
                //删除该角色下所有权限
                var res = await roleMenuInfoService.DeleteByIds(rmids);

                //添加该角色下所有的权限
                List <int> mRoot = new List <int>();
                //去掉父节点
                foreach (var item in roleMenuInfo.mIDs.Split(','))
                {
                    if ((await menuinfoService.QueryById(item)).mPid != 0)
                    {
                        mRoot.Add(int.Parse(item));
                    }
                }
                data.success = true;
                mRoot.ForEach(async rm =>
                {
                    data.success = data.success && await roleMenuInfoService.Add(new RoleMenuInfo(roleMenuInfo.rID, rm)) > 0;
                });
                if (data.success)
                {
                    data.msg = "分配权限成功!";
                }
                unitOfWork.CommitTran();
            }
            catch (Exception ex)
            {
                unitOfWork.RollbackTran();
            }
            return(data);
        }