package controllers import ( "encoding/json" "eta/eta_data_push/models" "eta/eta_data_push/utils" ) // 指标 type EdbInfoController struct { BaseAuthController } // @Title 获取基础指标详情 // @Description 获取基础指标详情 // @Param request body models.EdbInfoDetailReq true "type json string" // @Success 200 {object} models.EdbInfo // @router /detail [post] func (this *EdbInfoController) EdbIndexDetail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() var req models.EdbInfoDetailReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.EdbCode == "" { br.Msg = "请输入指标编码!" return } detail, err := models.GetEdbInfoByEdbCode(req.EdbCode) if err != nil { br.Msg = "获取数据失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } calculateList, err := models.GetEdbInfoCalculateMapping(req.EdbCode) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取数据失败!" br.ErrMsg = "获取计算指标失败,Err:" + err.Error() return } for _, v := range calculateList { baseEdbInfoList, err := models.GetEdbInfoCalculateBaseEdbInfo(v.EdbCode) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取数据失败!" br.ErrMsg = "获取计算指标所依赖的基础指标编码失败,Err:" + err.Error() return } v.BaseEdbInfoCode = baseEdbInfoList } detail.CalculateList = calculateList br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = detail } // @Title 获取指标信息 // @Description 获取指标信息 // @Param request body models.EdbInfoDetailReq true "type json string" // @Success 200 {object} models.EdbInfo // @router /item [post] func (this *EdbInfoController) EdbIndexItem() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() var req models.EdbInfoDetailReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.EdbCode == "" { br.Msg = "请输入指标编码!" return } item, err := models.GetEdbInfoItemByEdbCode(req.EdbCode) if err != nil { br.Msg = "获取数据失败!" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = item }