public async Task <IActionResult> GetAuthorizedModuleAsync() { var moduleService = Ioc.Get <IModuleService>(); var permissionService = Ioc.Get <IPermissionService>(); var moduleResult = await moduleService.GetAllAsync(); var permissions = await permissionService.GetAsync(CurrentRoleId); var treeResult = new List <TreeJsonModel>(); foreach (var item in moduleResult) { if (CurrentRoleId == "d3390e64-0ea4-47dc-9159-07c16ca905aa" || permissions.Any(p => p.AccessId == item.Id))//超级管理员角色拥有所有权限 { var model = new TreeJsonModel { Id = item.Id, ParentId = item.ParentId, Text = item.Name, Icon = item.Icon, Url = item.Url }; treeResult.Add(model); } } return(Ok(new StandardResult().Succeed(null, treeResult.ToTreeModel()))); }
public List <TreeJsonModel> GetAllTree() { AreaSearchCondition csc = new AreaSearchCondition() { OrderBy = EnumAreaSearchOrderBy.OrderById }; List <AreaEntity> ceListBuffer = new List <AreaEntity>(); List <TreeJsonModel> treeJsonModelBuffer = new List <TreeJsonModel>(); List <AreaEntity> ceList = _areaService.GetAreaByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.ParentId == 0) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.AreaName, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id); } return(treeJsonModelBuffer); }
public List <TreeJsonModel> GetJsonFromTreeModel(int nodeId) { AreaSearchCondition csc = new AreaSearchCondition() { OrderBy = EnumAreaSearchOrderBy.OrderById }; List <TreeJsonModel> datalist = new List <TreeJsonModel>(); List <AreaEntity> ceList = _areaService.GetBySuperArea(nodeId).ToList();//找出该级的子集; foreach (var ce in ceList) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.AreaName, Id = ce.Id }; datalist.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id); //自迭代; } if (ceList.Count == 0) //若遍历到末端,则: { return(null); } else { return(datalist); } }
public List <TreeJsonModel> GetAllTree() { ClassifySearchCondition csc = new ClassifySearchCondition() { OrderBy = EnumClassifySearchOrderBy.OrderById }; List <ClassifyEntity> ceListBuffer = new List <ClassifyEntity>(); List <TreeJsonModel> treeJsonModelBuffer = new List <TreeJsonModel>(); List <ClassifyEntity> ceList = _classifyService.GetClassifysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Classify == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id); } return(treeJsonModelBuffer); }
public List <TreeJsonModel> GetJsonFromTreeModel(int nodeId, int ifid = 0) { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById }; List <TreeJsonModel> datalist = new List <TreeJsonModel>(); List <CategoryEntity> ceList = _categoryService.GetCategorysBySuperFather(nodeId).ToList();//找出该级的子集; int i = 0; foreach (var ce in ceList) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id, // Father =ce.Father }; datalist.Add(TJM); if (ifid == 0) { TJM.children = GetJsonFromTreeModel(TJM.Id);//自迭代; } } if (ceList.Count == 0)//若遍历到末端,则: { return(null); } else { return(datalist); } }
public List<TreeJsonModel> GetAllTree() { AreaSearchCondition csc = new AreaSearchCondition() { OrderBy = EnumAreaSearchOrderBy.OrderById }; List<AreaEntity> ceListBuffer = new List<AreaEntity>(); List<TreeJsonModel> treeJsonModelBuffer = new List<TreeJsonModel>(); List<AreaEntity> ceList = _areaService.GetAreaByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.ParentId == 0) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.AreaName, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id); } return treeJsonModelBuffer; }
public async Task <IActionResult> GetAllAsync(string masterId) { var moduleService = Ioc.Get <IModuleService>(); var buttonService = Ioc.Get <IButtonService>(); var permissionService = Ioc.Get <IPermissionService>(); var moduleResult = await moduleService.GetAllAsync(); var buttonResult = await buttonService.GetAllAsync(); var permissions = await permissionService.GetAsync(masterId); var treeResult = new List <TreeJsonModel>(); foreach (var item in moduleResult) { var model = new TreeJsonModel { Id = item.Id, ParentId = item.ParentId, Text = item.Name, Icon = item.Icon, Url = item.Url, State = new State { Selected = permissions.Any(p => CurrentRoleId == "d3390e64-0ea4-47dc-9159-07c16ca905aa" || p.AccessId == item.Id) } //超级管理员角色拥有所有权限 }; treeResult.Add(model); } foreach (var item in buttonResult) { var model = new TreeJsonModel { Id = item.Id, ParentId = item.ModuleId, Text = item.Name, Icon = item.Icon, Url = item.Url, State = new State { Selected = permissions.Any(p => CurrentRoleId == "d3390e64-0ea4-47dc-9159-07c16ca905aa" || p.AccessId == item.Id) } //超级管理员角色拥有所有权限 }; treeResult.Add(model); } return(Ok(new StandardResult().Succeed(null, treeResult.ToTreeModel()))); }
public HttpResponseMessage GetNextNodesById(int nodeId) { try { ClassifyEntity ce = _classifyService.GetClassifyById(nodeId); TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; TJM.children = GetJsonFromTreeModel(TJM.Id); List <TreeJsonModel> treeJsonModelBuffer = TJM.children.ToList(); return(PageHelper.toJson(treeJsonModelBuffer.ToList())); } catch (Exception e) { var response = Request.CreateResponse(HttpStatusCode.OK); response.StatusCode = HttpStatusCode.OK; response.Content = new StringContent("获取失败"); // 响应内容 return(response); } }
public List <TreeJsonModel> GetCateANDPro() { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById, father = "NULL" }; List <CategoryEntity> ceListBuffer = new List <CategoryEntity>(); List <TreeJsonModel> treeJsonModelBuffer = new List <TreeJsonModel>(); List <CategoryEntity> ceList = _categoryService.GetCategorysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Father == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { List <CategoryEntity> ceList1 = _categoryService.GetCategorysBySuperFather(ce.Id).ToList();//找出该级的子集; TreeJsonModel TJM1 = null; foreach (var ce1 in ceList1) { TJM1 = new TreeJsonModel() { label = ce1.Name, Id = ce1.Id, //Father = ce1.Father }; TJM1.children = GetJsonModel(ce1.Id); //获取第三级分类跟分类下的前6个商品 treeJsonModelBuffer.Add(TJM1); } } return(treeJsonModelBuffer); }
public List <TreeJsonModel> GetAllTree(int ifid = 0) { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById }; List <CategoryEntity> ceListBuffer = new List <CategoryEntity>(); List <TreeJsonModel> treeJsonModelBuffer = new List <TreeJsonModel>(); List <CategoryEntity> ceList = _categoryService.GetCategorysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Father == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); if (ifid == 0)//如果ifid为0,那么直到查找到最后一级子类,否则只查到下一级 { TJM.children = GetJsonFromTreeModel(TJM.Id); } else { TJM.children = GetJsonFromTreeModel(TJM.Id, 1); } } return(treeJsonModelBuffer); }
public List<TreeJsonModel> GetJsonFromTreeModel(int nodeId,int ifid=0) { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById }; List<TreeJsonModel> datalist = new List<TreeJsonModel>(); List<CategoryEntity> ceList = _categoryService.GetCategorysBySuperFather(nodeId).ToList();//找出该级的子集; int i = 0; foreach (var ce in ceList) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id, // Father =ce.Father }; datalist.Add(TJM); if(ifid==0) TJM.children = GetJsonFromTreeModel(TJM.Id);//自迭代; } if (ceList.Count == 0)//若遍历到末端,则: { return null; } else { return datalist; } }
public List<TreeJsonModel> GetCateANDPro() { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById, father ="NULL" }; List<CategoryEntity> ceListBuffer = new List<CategoryEntity>(); List<TreeJsonModel> treeJsonModelBuffer = new List<TreeJsonModel>(); List<CategoryEntity> ceList = _categoryService.GetCategorysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Father == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { List<CategoryEntity> ceList1 = _categoryService.GetCategorysBySuperFather(ce.Id).ToList();//找出该级的子集; TreeJsonModel TJM1=null; foreach (var ce1 in ceList1) { TJM1 = new TreeJsonModel() { label = ce1.Name, Id = ce1.Id, //Father = ce1.Father }; TJM1.children = GetJsonModel(ce1.Id);//获取第三级分类跟分类下的前6个商品 treeJsonModelBuffer.Add(TJM1); } } return treeJsonModelBuffer; }
public List<TreeJsonModel> GetAllTree(int ifid=0) { CategorySearchCondition csc = new CategorySearchCondition() { OrderBy = EnumCategorySearchOrderBy.OrderById }; List<CategoryEntity> ceListBuffer = new List<CategoryEntity>(); List<TreeJsonModel> treeJsonModelBuffer = new List<TreeJsonModel>(); List<CategoryEntity> ceList = _categoryService.GetCategorysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Father == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); if(ifid==0)//如果ifid为0,那么直到查找到最后一级子类,否则只查到下一级 { TJM.children = GetJsonFromTreeModel(TJM.Id); } else { TJM.children = GetJsonFromTreeModel(TJM.Id,1); } } return treeJsonModelBuffer; }
public List<TreeJsonModel> GetJsonFromTreeModel(int nodeId) { ClassifySearchCondition csc = new ClassifySearchCondition() { OrderBy = EnumClassifySearchOrderBy.OrderById }; List<TreeJsonModel> datalist = new List<TreeJsonModel>(); List<ClassifyEntity> ceList = _classifyService.GetClassifysBySuperClassify(nodeId).ToList();//找出该级的子集; foreach (var ce in ceList) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; datalist.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id);//自迭代; } if (ceList.Count == 0)//若遍历到末端,则: { return null; } else { return datalist; } }
public List<TreeJsonModel> GetAllTree() { ClassifySearchCondition csc = new ClassifySearchCondition() { OrderBy = EnumClassifySearchOrderBy.OrderById }; List<ClassifyEntity> ceListBuffer = new List<ClassifyEntity>(); List<TreeJsonModel> treeJsonModelBuffer = new List<TreeJsonModel>(); List<ClassifyEntity> ceList = _classifyService.GetClassifysByCondition(csc).ToList(); foreach (var ce in ceList) { if (ce.Classify == null) { ceListBuffer.Add(ce);//查找第一级; } } foreach (var ce in ceListBuffer) { TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; treeJsonModelBuffer.Add(TJM); TJM.children = GetJsonFromTreeModel(TJM.Id); } return treeJsonModelBuffer; }
public HttpResponseMessage GetNextNodesById(int nodeId) { try { ClassifyEntity ce = _classifyService.GetClassifyById(nodeId); TreeJsonModel TJM = new TreeJsonModel() { label = ce.Name, Id = ce.Id }; TJM.children = GetJsonFromTreeModel(TJM.Id); List<TreeJsonModel> treeJsonModelBuffer = TJM.children.ToList(); return PageHelper.toJson(treeJsonModelBuffer.ToList()); } catch (Exception e) { var response = Request.CreateResponse(HttpStatusCode.OK); response.StatusCode = HttpStatusCode.OK; response.Content = new StringContent("获取失败"); // 响应内容 return response; } }