public bool CreateRoleMenu(ref List <string> result) { WXQ.BusinessCore.systemmanage.RoleOp roleOp = new RoleOp(0); List <Enties.Role> roles = roleOp.GetRoleList(); int roleId = 0; if (roles != null && roles.Count > 0) { roleId = roles[0].RoleId; } PageModel pageModel = new PageModel { PageIndex = 1, PageSize = 10000 }; #region 角色菜单关系 WXQ.BusinessCore.systemmanage.MenuOp menuOp = new MenuOp(0); ListResult <Enties.Menu> menus = menuOp.GetMenuList("", "", -1, pageModel); if (menus != null && menus.Result.Count > 0) { List <int> menuids = menus.Result.Select(m => m.MenuId).ToList(); if (menuOp.ModifyMentForRole(roleId, menuids)) { result.Add("添加角色菜单关系成功"); } else { result.Add("添加角色菜单关系失败"); } } #endregion 角色菜单关系 return(true); }
public bool CreateMenu(ref List <string> result) { WXQ.BusinessCore.systemmanage.MenuOp menuOp = new MenuOp(0); bool returnValue = true; int menuId = 0; #region 系统首页 WXQ.Enties.Menu sysindexMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "系统首页", ParentId = 0, Url = "dashboard", MenuType = 1 }; menuId = menuOp.InsertMenuReturnId(sysindexMenu); if (menuId > 0) { result.Add("添加菜单系统首页成功"); } else { result.Add("添加菜单系统首页失败"); } #endregion 系统首页 #region 系统管理 WXQ.Enties.Menu sysmanagerMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "系统管理", ParentId = 0, Url = "", MenuType = 1 }; menuId = menuOp.InsertMenuReturnId(sysmanagerMenu); if (menuId > 0) { result.Add("添加菜单系统管理成功"); int sysmanagerId = menuId; #region 用户 WXQ.Enties.Menu sysuserMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "用户", ParentId = sysmanagerId, Url = "", MenuType = 1 }; int usermenuId = menuOp.InsertMenuReturnId(sysuserMenu); if (usermenuId > 0) { result.Add("添加菜单用户成功"); #region 用户管理 WXQ.Enties.Menu usermanageMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "用户管理", ParentId = usermenuId, Url = "usermanage", MenuType = 1 }; if (menuOp.InsertMenuReturnId(usermanageMenu) > 0) { result.Add("添加菜单用户管理成功"); } else { result.Add("添加菜单用户管理失败"); } #endregion 用户管理 } else { result.Add("添加菜单用户失败"); } #endregion 用户 #region 角色 WXQ.Enties.Menu sysroleMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "角色管理", ParentId = sysmanagerId, Url = "", MenuType = 1 }; int rolemenuId = menuOp.InsertMenuReturnId(sysroleMenu); if (rolemenuId > 0) { result.Add("添加菜单角色管理成功"); #region 用户管理 WXQ.Enties.Menu rolemanageMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "角色", ParentId = rolemenuId, Url = "rolemanage", MenuType = 1 }; if (menuOp.InsertMenuReturnId(rolemanageMenu) > 0) { result.Add("添加菜单角色成功"); } else { result.Add("添加菜单角色失败"); } #endregion 用户管理 } else { result.Add("添加菜单角色管理失败"); } #endregion 角色 #region 部门 WXQ.Enties.Menu departmentmanageMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "部门管理", ParentId = sysmanagerId, Url = "", MenuType = 1 }; int departmentmanagermenuId = menuOp.InsertMenuReturnId(departmentmanageMenu); if (departmentmanagermenuId > 0) { result.Add("添加菜单部门管理成功"); #region 用户管理 WXQ.Enties.Menu departmentMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "部门", ParentId = departmentmanagermenuId, Url = "departmentmanage", MenuType = 1 }; if (menuOp.InsertMenuReturnId(departmentMenu) > 0) { result.Add("添加菜单部门成功"); } else { result.Add("添加菜单部门失败"); } #endregion 用户管理 } else { result.Add("添加菜单部门管理失败"); } #endregion 部门 } else { result.Add("添加菜单系统首页失败"); } #endregion 系统管理 #region 我的首页 WXQ.Enties.Menu myindexMenu = new Enties.Menu { Icon = "el-icon-menu", MenuName = "我的首页", ParentId = 0, Url = "myselfinfo", MenuType = 1 }; menuId = menuOp.InsertMenuReturnId(myindexMenu); if (menuId > 0) { result.Add("添加菜单我的首页成功"); } else { result.Add("添加菜单我的首页失败"); } #endregion 我的首页 if (returnValue) { result.Add("添加菜单成功"); } else { result.Add("添加菜单失败"); } return(returnValue); }