统一单入口 Go 工程与前端依赖目录,增加后台供应商配置、候选审核、计划预算、成交冲正、持仓复盘和站内通知。接入策略版本、Python 回测、可配置 A 股公开行情及 zap 文件轮转日志,补充迁移、契约与验证。
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"git.sundynix.cn/Blizzard/Veyra/internal/apperror"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func bindMarket(r *gin.Engine, o IdentityOptions) {
|
||||
for _, audience := range []string{"admin", "app"} {
|
||||
prefix := "/api/v1"
|
||||
if audience == "admin" {
|
||||
prefix = "/api/admin/v1"
|
||||
}
|
||||
g := r.Group(prefix, func(c *gin.Context) { authenticate(c, o, audience) })
|
||||
g.Use(func(c *gin.Context) {
|
||||
if o.Market == nil {
|
||||
fail(c, apperror.ErrUnavailable)
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
})
|
||||
g.GET("/instruments", func(c *gin.Context) {
|
||||
v, e := o.Market.List(c.Request.Context(), currentUser(c), c.Query("q"))
|
||||
if e != nil {
|
||||
fail(c, e)
|
||||
return
|
||||
}
|
||||
success(c, http.StatusOK, v)
|
||||
})
|
||||
g.GET("/market/history", func(c *gin.Context) {
|
||||
v, e := o.Market.History(c.Request.Context(), currentUser(c), c.Query("symbol"), c.Query("exchange"), c.Query("start"), c.Query("end"))
|
||||
if e != nil {
|
||||
fail(c, e)
|
||||
return
|
||||
}
|
||||
success(c, http.StatusOK, v)
|
||||
})
|
||||
if audience == "admin" {
|
||||
g.GET("/market/syncs", func(c *gin.Context) {
|
||||
v, e := o.Market.Tasks(c.Request.Context(), currentUser(c))
|
||||
if e != nil {
|
||||
fail(c, e)
|
||||
return
|
||||
}
|
||||
success(c, http.StatusOK, v)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user