123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- package controllers
- import (
- "eta/eta_hub/models"
- "eta/eta_hub/models/data_manage"
- "eta/eta_hub/utils"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- type EdbInfoController struct {
- BaseAuthController
- }
- 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
- }
- 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,
-
- 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),
-
-
- }
- 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
- }
|