package router

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"

	"go-admin/app/admin/apis"
	"go-admin/common/actions"
	"go-admin/common/middleware"
)

func init() {
	routerCheckRole = append(routerCheckRole, registerLinePreOrderRouter)
	routerNoCheckRole = append(routerNoCheckRole, unRegisterLinePreOrderRouter)
}

// registerLinePreOrderRouter
func registerLinePreOrderRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	api := apis.LinePreOrder{}
	r := v1.Group("/line-pre-order").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	{
		r.GET("", actions.PermissionAction(), api.GetPage)
		r.GET("/:id", actions.PermissionAction(), api.Get)
		r.POST("", api.Insert)
		r.PUT("/:id", actions.PermissionAction(), api.Update)
		r.DELETE("", api.Delete)

		r.POST("addOrder", actions.PermissionAction(), api.AddPreOrder) //添加订单
		// r.POST("position", actions.PermissionAction(), api.AddPosition)              //手动加仓
		r.POST("batchAddOrder", actions.PermissionAction(), api.BatchAddOrder)       //批量添加订单
		r.POST("quickAddPreOrder", actions.PermissionAction(), api.QuickAddPreOrder) //快捷下单
		r.POST("lever", actions.PermissionAction(), api.Lever)                       //设置杠杆
		r.POST("marginType", actions.PermissionAction(), api.MarginType)             //设置仓位模式
		r.POST("cancelOpenOrder", actions.PermissionAction(), api.CancelOpenOrder)   //取消委托
		r.POST("clearAll", actions.PermissionAction(), api.ClearAll)                 // 一键清除数据
		r.POST("getChildOrder", actions.PermissionAction(), api.GetChildOrderList)   // 获取子订单
		r.POST("closePosition", actions.PermissionAction(), api.ClosePosition)       // 平仓
		r.GET("getOrderPage", actions.PermissionAction(), api.GetOrderPage)          //订单列表
		r.POST("clearUnTriggered", actions.PermissionAction(), api.ClearUnTriggered) // 清除待触发的交易对
		r.POST("aiCoinPrice", actions.PermissionAction(), api.QueryAiCoinPrice)      //获取aiCoin买入点

		r.POST("/calculate", api.CalculateBreakEevenRatio) //计算亏损后止盈百分比

	}
}

func unRegisterLinePreOrderRouter(v1 *gin.RouterGroup) {
	api := apis.LinePreOrder{}
	r := v1.Group("/line-pre-order")
	{
		r.POST("queryOrder", api.QueryOrder) //查询订单
	}
}
