auth_controller.go 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package haitong
  2. import (
  3. "eta/eta_bridge/controller/resp"
  4. "eta/eta_bridge/global"
  5. "eta/eta_bridge/logic/xiangyu"
  6. xyReq "eta/eta_bridge/models/request/xiangyu"
  7. "github.com/gin-gonic/gin"
  8. "github.com/go-playground/validator/v10"
  9. )
  10. type SSOLoginController struct {
  11. }
  12. // SSOLogin
  13. // @Description: 用code换取token
  14. // @author: CH
  15. // @receiver xc
  16. // @datetime 2024-01-23 17:06:34
  17. // @param c *gin.Context
  18. func (xc *SSOLoginController) SSOLogin(c *gin.Context) {
  19. var req xyReq.GetTokenReq
  20. if e := c.Bind(&req); e != nil {
  21. err, ok := e.(validator.ValidationErrors)
  22. if !ok {
  23. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  24. return
  25. }
  26. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  27. return
  28. }
  29. if req.Code == "" {
  30. resp.FailMsg("请传入code码", "请输入指标code码", c)
  31. return
  32. }
  33. result, err, errMsg := xiangyu.LoginEta(req.Code)
  34. if err != nil {
  35. resp.FailData(errMsg, err.Error(), c)
  36. return
  37. }
  38. resp.OkData("获取成功", result, c)
  39. return
  40. }