12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package controllers
- import (
- "hongze/hongze_open_api/models/response/edb"
- "hongze/hongze_open_api/services/edb_data"
- )
- // EdbController 指标模块
- type EdbController struct {
- BaseAuth
- }
- // Detail
- // @Title 获取指标详情
- // @Description 图表变更通知的插入点接口
- // @Param unique_code query string true "指标唯一编码"
- // @Param request body chart.CreatChartCeluePushReq true "type json string"
- // @Success 200 创建成功
- // @router /detail [get]
- func (c *EdbController) Detail() {
- uniqueCode := c.GetString("unique_code")
- if uniqueCode == `` {
- c.FailWithMessage("指标编码必传")
- return
- }
- edbInfoDetail, err, errMsg := edb_data.EdbDetail(uniqueCode)
- if err != nil {
- if errMsg == `` {
- errMsg = "获取失败"
- }
- c.FailWithMessage(errMsg)
- return
- }
- dataList := make([]edb.EdbInfoSearchData, 0)
- if edbInfoDetail.DataList != nil && len(edbInfoDetail.DataList) > 0 {
- for _, data := range edbInfoDetail.DataList {
- dataList = append(dataList, edb.EdbInfoSearchData{
- DataTime: data.DataTime,
- Value: data.Value,
- })
- }
- }
- resp := edb.EdbInfoDetailResp{
- SourceName: edbInfoDetail.SourceName,
- EdbCode: edbInfoDetail.EdbCode,
- EdbName: edbInfoDetail.EdbName,
- Frequency: edbInfoDetail.Frequency,
- Unit: edbInfoDetail.Unit,
- StartDate: edbInfoDetail.StartDate,
- EndDate: edbInfoDetail.EndDate,
- UniqueCode: edbInfoDetail.UniqueCode,
- MinValue: edbInfoDetail.MinValue,
- MaxValue: edbInfoDetail.MaxValue,
- EdbNameEn: edbInfoDetail.EdbNameEn,
- UnitEn: edbInfoDetail.UnitEn,
- LatestDate: edbInfoDetail.LatestDate,
- LatestValue: edbInfoDetail.LatestValue,
- ChartImage: edbInfoDetail.ChartImage,
- DataList: dataList,
- }
- c.OkDetailed(resp, "获取成功")
- }
|