新增接口及接口文档
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"level_go/internal/model"
|
||||
"level_go/internal/service"
|
||||
)
|
||||
|
||||
type LimitBoardHandler struct {
|
||||
Service *service.LimitBoardService
|
||||
}
|
||||
|
||||
func NewLimitBoardHandler(s *service.LimitBoardService) *LimitBoardHandler {
|
||||
return &LimitBoardHandler{Service: s}
|
||||
}
|
||||
|
||||
func (h *LimitBoardHandler) GetOverview(c *gin.Context) {
|
||||
var req model.LimitBoardRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil || req.TradeDate == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "trade_date 参数不能为空"})
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := h.Service.GetLimitBoardOverview(req.TradeDate)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
Reference in New Issue
Block a user