public ActionResult ConfigAuth(int id) { RoleAuthModel model = new RoleAuthModel(); IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL"); //获取要分配角色的平台角色 T_PlatformRole role = platformRoleBll.GetEntity(m => m.Id == id); IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); //获取所有的菜单 var menuList = menuBll.GetList(m => m.MenuFlag == ConstantParam.MENU_LEFT && m.IsPlatform == ConstantParam.USER_TYPE_PLATFORM && m.ParentId == null).OrderBy(m => m.Order).ToList(); //Model赋值菜单列表 model.MenuList = menuList; //Model赋值要分配角色的平台角色 model.Role = new RoleModel() { RoleId = role.Id, RoleName = role.RoleName, RoleMemo = role.RoleMemo }; //获取该角色已经有的权限ID集合 model.ActionIds = role.PlatformRoleActions.Select(m => m.ActionId).ToList(); return(View(model)); }
public ActionResult ViewAuth(int id) { RoleAuthModel model = new RoleAuthModel(); IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL"); //获取要查看权限的平台角色 T_PlatformRole role = platformRoleBll.GetEntity(m => m.Id == id); //赋值 要查看权限的平台角色 model.Role = new RoleModel() { RoleId = role.Id, RoleName = role.RoleName, RoleMemo = role.RoleMemo }; //如果是普通角色 if (role.IsSystem == ConstantParam.USER_ROLE_DEFAULT) { //赋值 该角色所有的权限ID集合 model.ActionIds = role.PlatformRoleActions.Select(m => m.ActionId).ToList(); //Model赋值 该角色所关联的非重复菜单 var roleMenuList = role.PlatformRoleActions.Select(m => m.Action.Menu).Distinct().OrderBy(m => m.Order).ToList(); //新定义展示Model树形菜单 var menuList = new List <M_Menu>(); foreach (var menu in roleMenuList) { if (menu.ParentId != null) { if (!menuList.Contains(menu.ParentMenu)) { menuList.Add(menu.ParentMenu); } } menuList.Add(menu); } model.MenuList = menuList; } else { IActionBLL actionBll = BLLFactory <IActionBLL> .GetBLL("ActionBLL"); //赋值 所有的平台权限 model.ActionIds = actionBll.GetList(a => a.Menu.IsPlatform == ConstantParam.USER_TYPE_PLATFORM).Select(a => a.Id).ToList(); IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); //Model赋值 所有的平台菜单 model.MenuList = menuBll.GetList(m => m.IsPlatform == ConstantParam.USER_TYPE_PLATFORM).ToList(); } return(View(model)); }
/// <summary> /// 转到物业平台 /// </summary> /// <param name="id">小区ID</param> /// <returns></returns> public ActionResult GotoProperty(int id) { //获取session对象 UserSessionModel model = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; //构造菜单业务对象 IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); //获取菜单 var list = menuBll.GetList(m => m.MenuFlag == ConstantParam.MENU_LEFT && m.IsPlatform == ConstantParam.USER_TYPE_PROPERTY).Select(m => new MenuModel { MenuId = m.Id, MenuName = m.MenuName, MenuCode = m.MenuCode, MenuUrl = m.Href, MenuFlag = m.MenuFlag, MenuCss = m.IconClass, ParentId = m.ParentId, Order = m.Order, IsPlatform = m.IsPlatform }).ToList(); if (model.PropertyPlaceId == null) { //设置左边菜单 model.MenuList.AddRange(list); } //设置当前小区 model.PropertyPlaceId = id; //设置session信息 Session[ConstantParam.SESSION_USERINFO] = model; BreadCrumb.ClearState(); return(RedirectToAction("Index", "Property")); }
public async Task <TData <object> > GetPageListAndUserInfo() { var operatorInfo = await _operatorCache.Current(); var objMenu = await _menuBLL.GetList(null); var menuList = objMenu.Data; menuList = menuList.Where(p => p.MenuStatus == StatusEnum.Yes.ParseToInt()).ToList(); if (operatorInfo.IsSystem != 1) { var objMenuAuthorize = await _menuAuthorizeBLL.GetAuthorizeList(operatorInfo); var authorizeMenuIdList = objMenuAuthorize.Data.Select(p => p.MenuId).ToList(); menuList = menuList.Where(p => authorizeMenuIdList.Contains(p.Id)).ToList(); } #region 导航栏数据处理 var menuResult = new List <MenuResult>(); foreach (var menu in menuList.Where(p => p.ParentId == 0).OrderBy(p => p.MenuSort)) { var menu_a = new MenuResult(); menu_a.url = HttpHelper.IsUrl(menu.MenuUrl) ? menu.MenuUrl : "javascript:;"; menu_a.icon = menu.MenuIcon; menu_a.name = menu.MenuName; menu_a.subMenus = new List <MenuResult>(); foreach (var secondMenu in menuList.Where(p => p.ParentId == menu.Id).OrderBy(p => p.MenuSort)) { var menu_b = new MenuResult(); menu_b.url = HttpHelper.IsUrl(secondMenu.MenuUrl) ? secondMenu.MenuUrl : "javascript:;"; menu_b.name = secondMenu.MenuName; menu_b.url = secondMenu.MenuUrl; if (menuList.Where(p => p.ParentId == secondMenu.Id && p.MenuType != (int)MenuTypeEnum.Button) .Count() != 0) { menu_b.subMenus = new List <MenuResult>(); foreach (var thirdMenu in menuList.Where(p => p.ParentId == secondMenu.Id) .OrderBy(p => p.MenuSort)) { var menu_c = new MenuResult(); menu_c.url = HttpHelper.IsUrl(thirdMenu.MenuUrl) ? thirdMenu.MenuUrl : "javascript:;"; menu_c.name = thirdMenu.MenuName; menu_c.url = thirdMenu.MenuUrl; menu_b.subMenus.Add(menu_c); } } menu_a.subMenus.Add(menu_b); } menuResult.Add(menu_a); } #endregion var data = new TData <object>(); data.Tag = 1; data.Data = new { operatorInfo, menuResult }; return(data); }
/// <summary> /// 保存总公司用户的session信息 /// </summary> /// <param name="user"></param> private void SetUserSessiong(T_CompanyUser user, ICompanyUserBLL bll) { //用户session模型 UserSessionModel sessionInfo = new UserSessionModel(); //设置基本信息 sessionInfo.UserID = user.Id; sessionInfo.UserName = user.UserName; sessionInfo.TrueName = user.TrueName; sessionInfo.IsMgr = user.IsMgr; sessionInfo.UserType = ConstantParam.USER_TYPE_COMPANY; sessionInfo.CompanyId = user.CompanyId; sessionInfo.HeadPath = user.HeadPath; //构造菜单业务对象 IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); #region 设置总公司用户菜单以及权限 //管理员 if (user.IsMgr == ConstantParam.USER_ROLE_MGR) { //获取菜单 var list = menuBll.GetList(m => m.MenuFlag == ConstantParam.MENU_LEFT && m.IsPlatform == ConstantParam.USER_TYPE_COMPANY).Select(m => new MenuModel { MenuId = m.Id, MenuName = m.MenuName, MenuCode = m.MenuCode, MenuUrl = m.Href, MenuFlag = m.MenuFlag, MenuCss = m.IconClass, ParentId = m.ParentId, Order = m.Order, IsPlatform = m.IsPlatform }).ToList(); //设置左边菜单 sessionInfo.MenuList = list; } else { //获取总公司用户对应的角色权限表 var roleActions = user.CompanyUserRoles.Select(ur => ur.CompanyRole.CompanyRoleActions); //菜单字典 Dictionary <string, MenuModel> menuDic = new Dictionary <string, MenuModel>(); //权限字典 Dictionary <string, string> actionDic = new Dictionary <string, string>(); foreach (var item in roleActions) { var actions = item.Select(obj => obj.Action); foreach (var action in actions) { //添加权限 if (!actionDic.ContainsKey(action.Href)) { actionDic.Add(action.Href, action.ActionName); } foreach (var li in action.ActionItems) { //添加权限 if (!actionDic.ContainsKey(li.Href)) { actionDic.Add(li.Href, li.ItemName); } } var menu = action.Menu; if (menu.ParentId != null) { if (!menuDic.ContainsKey(menu.ParentMenu.MenuCode)) { menuDic.Add(menu.ParentMenu.MenuCode, GetMenuModel(menu.ParentMenu)); } } if (!menuDic.ContainsKey(menu.MenuCode)) { menuDic.Add(menu.MenuCode, GetMenuModel(menu)); } } } //设置菜单和权限 sessionInfo.MenuList.AddRange(menuDic.Values.ToList()); sessionInfo.ActionDic = actionDic; } #endregion //设置session信息 Session[ConstantParam.SESSION_USERINFO] = sessionInfo; }
public async Task <TData <List <MenuEntity> > > GetListJson([FromQuery] MenuListParam param) { var obj = await _menuBLL.GetList(param); return(obj); }