12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package index_data
- import (
- "eta_gn/eta_bridge/controller/resp"
- "eta_gn/eta_bridge/global"
- indexDataService "eta_gn/eta_bridge/services/index_data"
- "fmt"
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- )
- // PCSGIndexController 中石油新加坡指标
- type PCSGIndexController struct{}
- // GetBloombergIndexDataGeneral
- // @Description 获取通用格式数据
- // @Success 200 {string} string "获取成功"
- // @Router /bloomberg/index_data/general [post]
- func (this *PCSGIndexController) GetBloombergIndexDataGeneral(c *gin.Context) {
- var req struct {
- TaskKey string `json:"TaskKey" form:"TaskKey" description:"来源"`
- Frequency string `json:"Frequency" form:"Frequency" description:"频度"`
- }
- 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
- }
- fmt.Println(req)
- if req.TaskKey == "" {
- resp.Fail(fmt.Sprintf("参数有误, TaskKey: %s", req.TaskKey), c)
- return
- }
- if req.Frequency == "" {
- resp.Fail(fmt.Sprintf("参数有误, Frequency: %s", req.Frequency), c)
- return
- }
- data, e := indexDataService.GetPCSGBloombergGeneralIndex(req.TaskKey, req.Frequency)
- if e != nil {
- resp.FailMsg("获取失败", "GetPCSGBloombergGeneralIndex, err: "+e.Error(), c)
- return
- }
- resp.OkData("获取成功", data, c)
- }
|