feat: 接入 CoinGlass 清算热力图隔离链路
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled

This commit is contained in:
dela
2026-05-25 16:57:22 +08:00
parent e5fb54cb72
commit 1b61541ff5
32 changed files with 2550 additions and 70 deletions

View File

@@ -0,0 +1,50 @@
package v1
import (
"strconv"
"strings"
"github.com/gofiber/fiber/v2"
"cryptoHermes/internal/usecase"
)
type CoinglassDeps struct {
Enabled bool
Query *usecase.CoinglassQueryUsecase
}
func RegisterCoinglass(r fiber.Router, d CoinglassDeps) {
g := r.Group("/coinglass")
g.Get("/liq-heatmap", func(c *fiber.Ctx) error {
if !d.Enabled || d.Query == nil {
return fiber.NewError(fiber.StatusServiceUnavailable, "service-unavailable: coinglass disabled in config")
}
symbol := strings.ToUpper(strings.TrimSpace(c.Query("symbol")))
if symbol == "" {
return fiber.NewError(fiber.StatusBadRequest, "symbol is required")
}
interval := strings.TrimSpace(c.Query("interval", "5"))
if interval == "" {
interval = "5"
}
limit := 288
if l := c.Query("limit"); l != "" {
v, err := strconv.Atoi(l)
if err != nil || v <= 0 || v > 1000 {
return fiber.NewError(fiber.StatusBadRequest, "limit must be between 1 and 1000")
}
limit = v
}
rows, err := d.Query.GetLiqHeatMap(c.UserContext(), symbol, interval, limit)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return c.JSON(rows)
})
}