123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package haitong
- import (
- "encoding/json"
- "eta/eta_bridge/controller/resp"
- "eta/eta_bridge/global"
- "eta/eta_bridge/logic/htfutures"
- "fmt"
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- )
- type GetTokenReq struct {
- Code string `json:"code" form:"code" description:"code编码"`
- }
- type SSOLoginController struct {
- }
- // SSOLogin
- // @Description: 用code换取token
- // @author: CH
- // @receiver xc
- // @datetime 2024-01-23 17:06:34
- // @param c *gin.Context
- func (xc *SSOLoginController) SSOLogin(c *gin.Context) {
- var req GetTokenReq
- 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.Code == "" {
- resp.FailMsg("请传入code码", "请输入指标code码", c)
- return
- }
- result, err, errMsg := htfutures.LoginEta(req.Code)
- global.FILE_LOG.Info("oss 请求结束")
- if err != nil {
- resp.FailData(errMsg, err.Error(), c)
- return
- }
- str, err := json.Marshal(result)
- global.FILE_LOG.Info(fmt.Sprintf("请求成功,返回响应体:%s", str))
- resp.OkData("获取成功", result, c)
- return
- }
|