Checks / verify (push) Failing after 9m52s
统一单入口 Go 工程与前端依赖目录,增加后台供应商配置、候选审核、计划预算、成交冲正、持仓复盘和站内通知。接入策略版本、Python 回测、可配置 A 股公开行情及 zap 文件轮转日志,补充迁移、契约与验证。
74 lines
1.9 KiB
Go
74 lines
1.9 KiB
Go
package handler
|
|
|
|
import (
|
|
"git.sundynix.cn/Blizzard/Veyra/internal/apperror"
|
|
"git.sundynix.cn/Blizzard/Veyra/internal/service"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func bindTradePlans(r *gin.Engine, options IdentityOptions) {
|
|
group := r.Group("/api/v1", func(c *gin.Context) { authenticate(c, options, "app") })
|
|
group.Use(func(c *gin.Context) {
|
|
if options.Plans == nil {
|
|
fail(c, apperror.ErrUnavailable)
|
|
return
|
|
}
|
|
c.Next()
|
|
})
|
|
group.POST("/plan-previews", func(c *gin.Context) {
|
|
var input service.PlanPreviewInput
|
|
if !decode(c, &input) {
|
|
return
|
|
}
|
|
result, err := options.Plans.Preview(c.Request.Context(), currentUser(c), input)
|
|
if err != nil {
|
|
fail(c, err)
|
|
return
|
|
}
|
|
success(c, http.StatusCreated, result)
|
|
})
|
|
group.POST("/plan-previews/:id/confirm", func(c *gin.Context) {
|
|
var input struct{}
|
|
if !decode(c, &input) {
|
|
return
|
|
}
|
|
result, err := options.Plans.Confirm(c.Request.Context(), currentUser(c), c.Param("id"), c.Writer.Header().Get("X-Request-ID"))
|
|
if err != nil {
|
|
fail(c, err)
|
|
return
|
|
}
|
|
success(c, http.StatusOK, result)
|
|
})
|
|
group.GET("/plans", func(c *gin.Context) {
|
|
result, err := options.Plans.List(c.Request.Context(), currentUser(c))
|
|
if err != nil {
|
|
fail(c, err)
|
|
return
|
|
}
|
|
success(c, http.StatusOK, result)
|
|
})
|
|
group.POST("/plans/:id/cancel", func(c *gin.Context) {
|
|
var input struct {
|
|
ExpectedVersion int64 `json:"expected_version"`
|
|
}
|
|
if !decode(c, &input) {
|
|
return
|
|
}
|
|
result, err := options.Plans.Cancel(c.Request.Context(), currentUser(c), c.Param("id"), input.ExpectedVersion, c.Writer.Header().Get("X-Request-ID"))
|
|
if err != nil {
|
|
fail(c, err)
|
|
return
|
|
}
|
|
success(c, http.StatusOK, result)
|
|
})
|
|
group.GET("/accounts/:id/budget", func(c *gin.Context) {
|
|
result, err := options.Plans.Budget(c.Request.Context(), currentUser(c), c.Param("id"))
|
|
if err != nil {
|
|
fail(c, err)
|
|
return
|
|
}
|
|
success(c, http.StatusOK, result)
|
|
})
|
|
}
|