/// <summary> /// 保存菜单 /// </summary> /// <param name="menu"></param> /// <returns></returns> public MenuItem SaveMenu(MenuItem menu) { // Neusoft.Framework.Accessory.Context.ContextProcess _appContext = new Neusoft.Framework.Accessory.Context.ContextProcess(); //using (DaoManager _dao = new Neusoft.Framework.DataAccess.DaoManager()) //{ MenuLogic menuLogic = new MenuLogic(); //是新增菜单,插入 if (string.IsNullOrEmpty(menu.Id)) { menu.Id = this.GetSequence("PRIV.SEQ_MENUID"); menu.Order = int.Parse(this.GetSequence("PRIV.SEQ_MENUORDER")); int i = menuLogic.Insert(menu); if (i <= 0) { return(null); } } else //更新 { int i = menuLogic.Update(menu); if (i <= 0) { return(null); } } //} return(menu); }
/// <summary> /// 查询菜单列表列表 /// </summary> /// <param name="typeRes"></param> /// <returns></returns> public static IList <MenuItem> QueryResByType(string typeRes) { using (MenuLogic _logic = new MenuLogic()) { return(_logic.QueryResByType(typeRes)); } }
/// <summary> /// 查询用户菜单列表 /// </summary> /// <param name="userId"></param> /// <returns></returns> public static IList <MenuItem> QueryMenuByUser(string userId) { using (MenuLogic _logic = new MenuLogic()) { return(_logic.QueryByUserID(userId)); } }
/// <summary> /// 根据角色查询拥有菜单 /// </summary> /// <param name="roleId"></param> /// <returns></returns> public static IList <MenuItem> QueryMenuByRole(string roleId) { using (MenuLogic _logic = new MenuLogic()) { return(_logic.Query(roleId)); } }
/// <summary> /// 查询全部菜单 /// </summary> /// <returns></returns> public static IList <MenuItem> QueryMenu() { using (MenuLogic _logic = new MenuLogic()) { return(_logic.Query()); } }
/// <summary> /// 删除菜单 /// </summary> /// <param name="menuId"></param> /// <returns></returns> public static int DeleteMenu(string menuId) { //删除菜单本身 using (MenuLogic _logic = new MenuLogic()) { return(_logic.Delete(menuId)); } //删除子菜单 }
/// <summary> /// 添加角色菜单授权 /// </summary> /// <param name="newRoles"></param> /// <param name="newMenus"></param> /// <returns></returns> public static int AddRoleMenuMap(List <string> newRoles, List <string> newMenus) { MenuLogic _logic = new MenuLogic();; //using (DaoManager _dao = new Neusoft.Framework.DataAccess.DaoManager()) //{ foreach (string roleid in newRoles) { IList <MenuItem> _menus = _logic.Query(roleid); //如果已存在的菜单id不在newMenus中,级联删除该对照关系 foreach (MenuItem _menu in _menus) { if (!newMenus.Contains(_menu.Id)) { if (_logic.DeleteRoleMenuMap(roleid, _menu.Id) <= 0) { return(-1); } } } //如果newMenus中不在_menus中,新增 foreach (string menuId in newMenus) { if (!menuContains(_menus, menuId)) { if (_logic.InsertRoleMenuMap(roleid, menuId) <= 0) { return(-1); } } } } //} return(0); }