Эх сурвалжийг харах

Merge branch 'feature/jiayue' into debug

hsun 1 жил өмнө
parent
commit
e6df2d758d

+ 5 - 1
controller/index_data/jiayue_index.go

@@ -167,10 +167,14 @@ func (j *JiaYueIndexController) GetRecentNewIndex(c *gin.Context) {
 // @Success 200 {string} string "获取成功"
 // @Router /jiayue/menu_list [post]
 func (j *JiaYueIndexController) GetMenuList(c *gin.Context) {
-	data, e := jiayue.GetDictCategory(``, make([]interface{}, 0), "")
+	categories, e := jiayue.GetDictCategory(``, make([]interface{}, 0), "")
 	if e != nil {
 		resp.FailMsg("获取失败", "获取嘉业指标目录列表, err: "+e.Error(), c)
 		return
 	}
+	data := make([]*response.IndexMenuData, 0)
+	for _, v := range categories {
+		data = append(data, indexDataService.FormatJiaYueDictCategory2Resp(v))
+	}
 	resp.OkData("获取成功", data, c)
 }

+ 22 - 14
services/index_data/jiayue_platform.go

@@ -55,7 +55,7 @@ func GetIndexFromJiaYue(indexCode string, sourceArr []string) (data *response.In
 		indexData []jiayue.DictData
 		dictMenu  []jiayue.DictCategory
 	)
-	data = FormatItem2Resp(index, indexData, dictMenu)
+	data = FormatJiaYueIndexItem2Resp(index, indexData, dictMenu)
 	return
 }
 
@@ -131,7 +131,7 @@ func GetIndexAndDataFromJiaYue(indexCode, startDate, endDate string, sourceArr [
 		err = fmt.Errorf("GetDictCategory err: %s", e.Error())
 		return
 	}
-	data = FormatItem2Resp(index, indexData, menus)
+	data = FormatJiaYueIndexItem2Resp(index, indexData, menus)
 	return
 }
 
@@ -251,14 +251,14 @@ func GetNewIndexAndDataFromJiaYue() (indexList []*response.IndexResp, err error)
 			indexData []jiayue.DictData
 			dictMenu  []jiayue.DictCategory
 		)
-		item := FormatItem2Resp(v, indexData, dictMenu)
+		item := FormatJiaYueIndexItem2Resp(v, indexData, dictMenu)
 		indexList = append(indexList, item)
 	}
 	return
 }
 
-// FormatItem2Resp 格式化指标响应体
-func FormatItem2Resp(item jiayue.DictIndex, dictData []jiayue.DictData, dictMenu []jiayue.DictCategory) (res *response.IndexResp) {
+// FormatJiaYueIndexItem2Resp 格式化指标响应体
+func FormatJiaYueIndexItem2Resp(item jiayue.DictIndex, dictData []jiayue.DictData, dictMenu []jiayue.DictCategory) (res *response.IndexResp) {
 	res = new(response.IndexResp)
 	res.Id = item.Id
 	res.IndexCode = item.Code
@@ -280,15 +280,23 @@ func FormatItem2Resp(item jiayue.DictIndex, dictData []jiayue.DictData, dictMenu
 	}
 	if len(dictMenu) > 0 {
 		firstMenu := dictMenu[0]
-		res.MenuData.Id = firstMenu.Id
-		res.MenuData.Type = firstMenu.Type
-		res.MenuData.Code = firstMenu.Code
-		res.MenuData.Name = firstMenu.Name
-		res.MenuData.Icon = firstMenu.Icon
-		res.MenuData.Sort = firstMenu.Sorting
-		res.MenuData.ParentId = firstMenu.ParentId
-		res.MenuData.ParentName = firstMenu.ParentName
-		res.MenuData.Path = firstMenu.Path
+		r := FormatJiaYueDictCategory2Resp(firstMenu)
+		res.MenuData = *r
 	}
 	return
 }
+
+// FormatJiaYueDictCategory2Resp 格式化指标目录响应体
+func FormatJiaYueDictCategory2Resp(item jiayue.DictCategory) (res *response.IndexMenuData) {
+	res = new(response.IndexMenuData)
+	res.Id = item.Id
+	res.Type = item.Type
+	res.Code = item.Code
+	res.Name = item.Name
+	res.Icon = item.Icon
+	res.Sort = item.Sorting
+	res.ParentId = item.ParentId
+	res.ParentName = item.ParentName
+	res.Path = item.Path
+	return
+}