github.com/99MyCql/duffett@v0.1.0/app/data/api.go (about)

     1  package data
     2  
     3  import (
     4  	"net/http"
     5  
     6  	log "github.com/sirupsen/logrus"
     7  
     8  	"github.com/gin-gonic/gin"
     9  
    10  	"github.com/99MyCql/duffett/pkg"
    11  )
    12  
    13  // @Summary Tushare
    14  // @Tags Data
    15  // @Accept json
    16  // @Param Authorization header string false "Bearer <token>"
    17  // @Param data body TushareReq true "data"
    18  // @Success 200 {string} json "{"code":0,"data":{},"msg":""}"
    19  // @Failure 200 {string} json "{"code":非0,"data":{},"msg":""}"
    20  // @Router /api/v1/data/tushare [post]
    21  func Tushare(c *gin.Context) {
    22  	var req TushareReq
    23  	if err := c.ShouldBind(&req); err != nil {
    24  		log.Error(err)
    25  		c.JSON(http.StatusOK, pkg.ClientErr(err.Error()))
    26  		return
    27  	}
    28  	log.Debug(req)
    29  
    30  	rsp, err := ReqTushareApi(req)
    31  	if err != nil {
    32  		log.Error(err)
    33  		c.JSON(http.StatusOK, pkg.ServerErr("服务端请求 tushare 接口时发生了一些错误"))
    34  		return
    35  	}
    36  	c.JSON(http.StatusOK, rsp)
    37  }