/// <summary> /// 根据角色id获取角色权限绑定Ztree展示 /// </summary> /// <param name="roleId"></param> /// <returns></returns> public List <ServPurviewInfoCustom> GetPurviewInfoByRoleId(int roleId) { try { //查询角色权限绑定 List <ServRolePurviewModel> rolePurviewList = servRolePurviewDAL.GetRolePurviewByRoleId(roleId); //查询所有的园区 List <BaseRegionConfigModel> regionList = baseRegionConfigDAL.GetAllRegionConfig(); //查询所有的权限 ServPurviewInfoQuery query = new ServPurviewInfoQuery(); List <ServPurviewInfoModel> purviewList = servPurviewInfoDAL.GetEntities(query); //List<EnumModel> purviewList = EnumClass.GetEnumModelList<EnumClass.PurviewEnum>(); ServPurviewInfoCustom purviewCustom; List <ServPurviewInfoCustom> purviewCustomList = new List <ServPurviewInfoCustom>(); for (int j = 0; j < regionList.Count; j++) { purviewCustom = new ServPurviewInfoCustom(); purviewCustom.id = regionList[j].id; purviewCustom.pid = -1; purviewCustom.sid = regionList[j].id; purviewCustom.purview_code = 0; purviewCustom.purview_name = regionList[j].region_name; purviewCustomList.Add(purviewCustom); for (int i = 0; i < purviewList.Count; i++) { purviewCustom = new ServPurviewInfoCustom(); purviewCustom.id = purviewList[i].id; //如果权限的pid=-1则pid绑定为园区id if (purviewList[i].pid == -1) { purviewCustom.pid = regionList[j].id; } else { purviewCustom.pid = Convert.ToInt32(purviewList[i].pid + "" + regionList[j].id);; } purviewCustom.sid = Convert.ToInt32(purviewList[i].purview_code + "" + regionList[j].id); purviewCustom.purview_code = purviewList[i].purview_code; purviewCustom.purview_name = purviewList[i].purview_name; ServRolePurviewModel rolePurviewModel = rolePurviewList.FirstOrDefault(n => n.purview_id == purviewList[i].purview_code && n.region_id == regionList[j].id); if (rolePurviewModel != null) { purviewCustom.@checked = true; } else { purviewCustom.@checked = false; } purviewCustomList.Add(purviewCustom); } } return(purviewCustomList); } catch (Exception ex) { throw ex; } }
//ServPersonRoleDAL servPersonRoleDAL = new ServPersonRoleDAL(); #region 权限管理 /// <summary> /// 获取权限树 /// </summary> /// <returns></returns> public List <ServPurviewInfoModel> GetPurviewTree() { try { ServPurviewInfoQuery query = new ServPurviewInfoQuery(); List <ServPurviewInfoModel> purviewList = servPurviewInfoDAL.GetEntities(query); return(purviewList); } catch (Exception ex) { throw ex; } }