/// <summary> /// 获取产品分类列表(递归不分页) /// </summary> /// <returns></returns> public List <ProductTypeLevelAllInfoResponse> GetProductTypeList() { var productTypeList = pocProductTypeRepository.GetProductType(); var fatherTypeList = productTypeList.Where(x => x.ParentGuid == Guid.Parse("00000000-0000-0000-0000-000000000000")); List <ProductTypeLevelAllInfoResponse> list = new List <ProductTypeLevelAllInfoResponse>(); foreach (var data in fatherTypeList) { ProductTypeLevelAllInfoResponse model = new ProductTypeLevelAllInfoResponse(); List <string> li = new List <string>(); li.Add(data.ProductTypeName); model.id = data.Id; model.isStart = data.IsEnabled; model.level = data.ProductTypeLevelName; model.levelSort = data.ProductTypeLevelNo; model.productTypeGuid = data.ProductTypeGuid; model.showLevel = li; model.remark = data.Remark; model.className = data.ProductTypeName; model.createdDate = data.CreatedDate; model.parentGuid = data.ParentGuid; model.children = GetChildAllIno(data.ProductTypeGuid, productTypeList); list.Add(model); } return(list); }
/// <summary> /// 获取递归产品分类全部数据 /// </summary> /// <returns></returns> public List <ProductTypeLevelAllInfoResponse> GetChildAllIno(Guid id, List <T_POC_ProductType> productTypeList) { List <ProductTypeLevelAllInfoResponse> childrenList = new List <ProductTypeLevelAllInfoResponse>(); var childs = productTypeList.Where(x => x.ParentGuid == id); foreach (var item in childs) { ProductTypeLevelAllInfoResponse father = new ProductTypeLevelAllInfoResponse(); List <string> li = new List <string>(); li.Add(item.ProductTypeName); father.id = item.Id; father.isStart = item.IsEnabled; father.level = item.ProductTypeLevelName; father.levelSort = item.ProductTypeLevelNo; father.productTypeGuid = item.ProductTypeGuid; father.remark = item.Remark; father.className = item.ProductTypeName; father.createdDate = item.CreatedDate; father.parentGuid = item.ParentGuid; father.parentName = productTypeList.Where(x => x.ProductTypeGuid == item.ParentGuid).FirstOrDefault().ProductTypeName; ShowLevel(item.ParentGuid, productTypeList, li); father.showLevel = li; father.children = GetChildAllIno(item.ProductTypeGuid, productTypeList); childrenList.Add(father); } if (childs.Count() <= 0) { return(null); } return(childrenList); }