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, registerLineDirectionRouter)
	routerNoVersion = append(routerNoVersion, registerLineDirectionNoVersionRouter)
}

func registerLineDirectionNoVersionRouter(v1 *gin.RouterGroup) {
	api := apis.LineDirection{}

	group := v1.Group("/Direction")
	{
		group.POST("addDirection", api.AddDirection) // 新增预估方向
	}
}

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

		r.PUT("/reload-group", api.ReloadGroupData)
	}
}
