瀏覽代碼

Merge branch 'industry_map'

rdluck 4 年之前
父節點
當前提交
ddbcae0e1b
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      services/industry_map.go

+ 5 - 1
services/industry_map.go

@@ -84,7 +84,7 @@ func GetIndustryTree()(rootNode *models.CygxIndustryMapItems, err error) {
 //获取对应的层级map
 func getMap(tree *models.CygxIndustryMapItems,item *models.CygxIndustryMapItems,hasIdMap map[int]string,otherChildMapSlice map[int][]*models.CygxIndustryMapItems){
 	//深度
-	depth := 0
+	depth := 1
 
 	//获取下级
 	childTree := getChildTree(tree,item)
@@ -120,6 +120,7 @@ func GetIndustryMapNameSlice(industryName string)(nameSlice []string,err error){
 	tree,err := GetIndustryTree()
 	if err != nil{
 		fmt.Println("获取树失败")
+		return
 	}
 
 	//fmt.Println(tree)
@@ -129,6 +130,7 @@ func GetIndustryMapNameSlice(industryName string)(nameSlice []string,err error){
 	itemList,err := models.GetFirstCygxIndustryListByName(industryName)
 	if err != nil{
 		fmt.Println("获取数据失败,",err)
+		return
 	}
 	//找不到对应的数据
 	if len(itemList) <= 0{
@@ -157,6 +159,8 @@ func GetIndustryMapNameSlice(industryName string)(nameSlice []string,err error){
 	otherChildMapSlice := map[int][]*models.CygxIndustryMapItems{}
 	for _,item := range list{
 		hasIdMap[item.IndustryMapId]=""
+		//将自己的节点给加进去
+		otherChildMapSlice[0] = append(otherChildMapSlice[0],item)
 		getMap(tree,item,hasIdMap,otherChildMapSlice)
 	}
 	var tmpSlice []*models.CygxIndustryMapItems