package data import ( "eta/eta_api/models/data_manage" "eta/eta_api/utils" "fmt" ) func GetClassifyALLById(classifyId int) (items []*data_manage.BaseFromEiaSteoClassify, err error) { classify, err := data_manage.GetEiaSteoClassifyById(classifyId) if err != nil { return } if classify.Level == 1 { childClassify, er := data_manage.GetChildEiaSteoClassifyById(classifyId) if er != nil { err = er return } items = append(items, childClassify...) } // 兼容之前部分指标在一级分类下的情况 if len(items) == 0 { items = append(items, classify) } return } type EiaSteoIndexSource2EdbReq struct { EdbCode string EdbName string Frequency string Unit string ClassifyId int AdminId int AdminRealName string } // EiaSteoIndexSource2Edb 新增eiaSteo数据源到指标库 func EiaSteoIndexSource2Edb(req EiaSteoIndexSource2EdbReq, lang string) (edb *data_manage.EdbInfo, err error, errMsg string, skip bool) { if req.EdbCode == "" { err = fmt.Errorf("指标ID为空") return } defer func() { if err != nil { tips := fmt.Sprintf("EiaSteoIndexSource2Edb新增失败, Err: %s", err.Error()) fmt.Println(tips) utils.FileLog.Info(tips) } }() source := utils.DATA_SOURCE_EIA_STEO // 是否新增过指标 exist, e := data_manage.GetEdbInfoByEdbCode(source, req.EdbCode) if e != nil && e.Error() != utils.ErrNoRow() { err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error()) return } if exist != nil { skip = true return } // 开始结束时间 var startDate, endDate string // 新增指标库 edbInfo, e, msg, _ := EdbInfoAdd(source, utils.DATA_SUB_SOURCE_EDB, req.ClassifyId, req.EdbCode, req.EdbName, req.Frequency, req.Unit, startDate, endDate, req.AdminId, req.AdminRealName, lang) if e != nil { errMsg = msg err = fmt.Errorf("EdbInfo: 新增指标失败, err: %s", e.Error()) return } edb = edbInfo return }