Prechádzať zdrojové kódy

fix:涌益指标搜索增加父级分类id

zqbao 6 mesiacov pred
rodič
commit
2a0c882134

+ 17 - 0
controllers/data_manage/yongyi_data.go

@@ -263,6 +263,23 @@ func (this *EdbInfoController) YongyiSearchList() {
 			return
 		}
 	}
+	classifyIds := make([]int, 0)
+	for _, v := range list {
+		classifyIds = append(classifyIds, v.ClassifyId)
+	}
+	classifyList, err := data_manage.GetBaseFromYongyiClassifyByIds(classifyIds)
+	if err != nil {
+		br.Msg = "搜索失败"
+		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
+		return
+	}
+	classifyMap := make(map[int]int)
+	for _, v := range classifyList {
+		classifyMap[v.ClassifyId] = v.ParentId
+	}
+	for _, v := range list {
+		v.ParentClassifyId = classifyMap[v.ClassifyId]
+	}
 
 	br.Ret = 200
 	br.Success = true

+ 5 - 4
models/data_manage/base_from_yongyi.go

@@ -147,10 +147,11 @@ type BaseFromYongyiData struct {
 }
 
 type BaseFromYongyiIndexSearchItem struct {
-	YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
-	ClassifyId    int
-	IndexCode     string
-	IndexName     string
+	YongyiIndexId    int `orm:"column(yongyi_index_id);pk"`
+	ClassifyId       int
+	ParentClassifyId int
+	IndexCode        string
+	IndexName        string
 }
 
 // GetYongyiItemList 模糊查询Yongyi数据库指标列表

+ 3 - 0
models/data_manage/base_from_yongyi_classify.go

@@ -46,6 +46,9 @@ func GetBaseFromYongyiClassifyById(classifyId int) (item *BaseFromYongyiClassify
 
 // GetBaseFromYongyiClassifyById 通过分类id的获取分类信息
 func GetBaseFromYongyiClassifyByIds(classifyIds []int) (items []*BaseFromYongyiClassify, err error) {
+	if len(classifyIds) == 0 {
+		return
+	}
 	o := orm.NewOrmUsingDB("data")
 	sql := `SELECT * FROM base_from_yongyi_classify WHERE classify_id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `) `
 	_, err = o.Raw(sql, classifyIds).QueryRows(&items)