// Package data // @Author gmy 2024/8/12 16:09:00 package data import "eta/eta_api/models/data_manage" // LyClassifyList 获取分类列表 包含 分类下的指标名称 func LyClassifyList() ([]*data_manage.BaseFromLyClassifyAndIndexInfo, error) { // step_1 获取分类列表 lyClassify, err := data_manage.GetAllLyClassify() if err != nil { return nil, err } // step_2 分类id列表 classifyIds := make([]int, 0) for _, v := range lyClassify { classifyIds = append(classifyIds, v.BaseFromLyClassifyId) } // step_3 获取分类下的指标 lyIndices, err := data_manage.GetLyIndexByClassifyIds(classifyIds) if err != nil { return nil, err } // step_4 封装返回 lyClassifyAndIndexInfos := make([]*data_manage.BaseFromLyClassifyAndIndexInfo, 0) for _, classify := range lyClassify { lyClassifyAndIndexInfo := &data_manage.BaseFromLyClassifyAndIndexInfo{ BaseFromLyClassifyId: classify.BaseFromLyClassifyId, CreateTime: classify.CreateTime, ModifyTime: classify.ModifyTime, ClassifyName: classify.ClassifyName, ParentId: classify.ParentId, Sort: classify.Sort, ClassifyNameEn: classify.ClassifyNameEn, } for _, lyIndex := range lyIndices { if classify.BaseFromLyClassifyId == lyIndex.BaseFromLyClassifyId { lyClassifyAndIndexInfo.IndexId = lyIndex.BaseFromLyIndexId lyClassifyAndIndexInfo.IndexCode = lyIndex.IndexCode lyClassifyAndIndexInfo.IndexName = lyIndex.IndexName } } lyClassifyAndIndexInfos = append(lyClassifyAndIndexInfos, lyClassifyAndIndexInfo) } return lyClassifyAndIndexInfos, nil }