123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- package controllers
- import (
- "eta/eta_hub/models"
- "eta/eta_hub/models/data_manage"
- "eta/eta_hub/utils"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- // EdbInfoController 数据管理
- type EdbInfoController struct {
- BaseAuthController
- }
- // EiaSteoClassify
- // @Title EiaSteo数据分类
- // @Description EiaSteo数据分类接口
- // @Success 200 {object} data_manage.LzClassify
- // @router /eia_steo/classify [get]
- func (this *EdbInfoController) EiaSteoClassify() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- classifyList, err := data_manage.GetEiaSteoClassifyList()
- if err != nil {
- br.Msg = "获取分类失败"
- br.ErrMsg = "获取分类失败,Err:" + err.Error()
- return
- }
- for _, v := range classifyList {
- if v.ClassifyName == `` {
- v.ClassifyName = v.ClassifyNameOriginal
- }
- }
- br.Ret = 200
- br.Msg = "获取成功"
- br.Data = classifyList
- }
- // EiaSteoData
- // @Title 获取EiaSteo数据
- // @Description 获取EiaSteo数据接口
- // @Param BaseFromEiaSteoClassifyId query int true "指标分类id"
- // @Param IndexCode query string true "指标code"
- // @Param IsExport query bool false "是否导出excel,默认是false"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} data_manage.LzFrequency
- // @router /eia_steo/data [get]
- func (this *EdbInfoController) EiaSteoData() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- indexCode := this.GetString("IndexCode")
- if indexCode != "" {
- condition += ` AND index_code = ? `
- pars = append(pars, utils.TrimStr(indexCode))
- }
- classifyId, _ := this.GetInt("BaseFromEiaSteoClassifyId")
- if classifyId > 0 {
- condition += ` AND base_from_eia_steo_classify_id = ? `
- pars = append(pars, classifyId)
- }
- //获取指标
- indexList, err := data_manage.GetEiaSteoIndexList(condition, pars)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resultList := make([]data_manage.EiaSteoIndexListResp, 0)
- for _, v := range indexList {
- indexName := v.IndexName
- if indexName == `` {
- indexName = v.IndexNameOriginal
- }
- product := data_manage.EiaSteoIndexListResp{
- BaseFromEiaSteoIndexId: v.BaseFromEiaSteoIndexId,
- BaseFromEiaSteoClassifyId: v.BaseFromEiaSteoClassifyId,
- IndexCode: v.IndexCode,
- IndexName: indexName,
- //IndexNameOriginal: v.IndexNameOriginal,
- Unit: v.Unit,
- Frequency: v.Frequency,
- StartDate: v.StartDate.Format(utils.FormatDate),
- EndDate: v.EndDate.Format(utils.FormatDate),
- ModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
- CreateTime: v.CreateTime.Format(utils.FormatDateTime),
- //Paging: tmpPaging,
- //DataList: nil,
- }
- total, err := data_manage.GetEiaSteoIndexDataCount(v.IndexCode)
- page := paging.GetPaging(currentIndex, pageSize, total)
- dataList, err := data_manage.GetEiaSteoIndexDataList(v.IndexCode, startSize, pageSize)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
- return
- }
- if dataList == nil {
- dataList = make([]*data_manage.BaseFromEiaSteoDataItem, 0)
- }
- product.DataList = dataList
- product.Paging = page
- resultList = append(resultList, product)
- }
- br.Ret = 200
- br.Msg = "获取成功"
- br.Data = resultList
- }
|