123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package index_data
- import (
- "eta_gn/eta_bridge/controller/resp"
- "eta_gn/eta_bridge/global"
- indexDataReq "eta_gn/eta_bridge/models/request/index_data"
- "eta_gn/eta_bridge/models/response"
- indexDataService "eta_gn/eta_bridge/services/index_data"
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- )
- // GnIndexController 国能指标
- type GnIndexController struct{}
- // GetPageIndex
- // @Description 获取国能指标列表-分页
- // @Success 200 {string} string "获取成功"
- // @Router /gn/page_index [post]
- func (j *GnIndexController) GetPageIndex(c *gin.Context) {
- var req indexDataReq.GnPageIndexReq
- if e := c.Bind(&req); e != nil {
- err, ok := e.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+e.Error(), c)
- return
- }
- resp.FailData("参数解析失败", err.Translate(global.Trans), c)
- return
- }
- list, page, err := indexDataService.GetPageIndexesFromGn(req.PageIndex, req.PageSize, req.LastModifyTime, req.IndexId)
- if err != nil {
- resp.FailMsg("查询失败", err.Error(), c)
- return
- }
- data := response.GnPageIndexResp{
- Page: page,
- List: list,
- }
- resp.OkData("操作成功", data, c)
- return
- }
- // GetIndexData
- // @Description 获取国能指标数据
- // @Success 200 {string} string "获取成功"
- // @Router /gn/index_data [post]
- func (j *GnIndexController) GetIndexData(c *gin.Context) {
- var req indexDataReq.GnDataReq
- if e := c.Bind(&req); e != nil {
- err, ok := e.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+e.Error(), c)
- return
- }
- resp.FailData("参数解析失败", err.Translate(global.Trans), c)
- return
- }
- if req.IndexCode == "" {
- resp.FailMsg("请输入指标code码", "请输入指标code码", c)
- return
- }
- data, e := indexDataService.GetIndexAndDataFromGn(req.IndexCode, req.StartDate, req.EndDate)
- if e != nil {
- resp.FailMsg("获取失败", "获取国能指标数据失败, err: "+e.Error(), c)
- return
- }
- resp.OkData("获取成功", data, c)
- return
- }
|