package routes

import (
	"github.com/gofiber/fiber/v2"

	"github.com/break/junhong_cmp_fiber/internal/handler/admin"
	"github.com/break/junhong_cmp_fiber/internal/model/dto"
	"github.com/break/junhong_cmp_fiber/pkg/openapi"
)

// registerPollingManualTriggerRoutes 注册轮询手动触发路由
func registerPollingManualTriggerRoutes(router fiber.Router, handler *admin.PollingManualTriggerHandler, doc *openapi.Generator, basePath string) {
	group := router.Group("/polling-manual-trigger")
	groupPath := basePath + "/polling-manual-trigger"

	Register(group, doc, groupPath, "POST", "/single", handler.TriggerSingle, RouteSpec{
		Summary: "单卡手动触发",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   new(dto.TriggerSingleReq),
		Output:  nil,
		Auth:    true,
	})

	Register(group, doc, groupPath, "POST", "/batch", handler.TriggerBatch, RouteSpec{
		Summary: "批量手动触发",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   new(dto.TriggerBatchReq),
		Output:  new(dto.ManualTriggerLogResp),
		Auth:    true,
	})

	Register(group, doc, groupPath, "POST", "/by-condition", handler.TriggerByCondition, RouteSpec{
		Summary: "条件筛选触发",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   new(dto.TriggerByConditionReq),
		Output:  new(dto.ManualTriggerLogResp),
		Auth:    true,
	})

	Register(group, doc, groupPath, "GET", "/status", handler.GetStatus, RouteSpec{
		Summary: "获取手动触发状态",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   nil,
		Output:  new(dto.ManualTriggerStatusResp),
		Auth:    true,
	})

	Register(group, doc, groupPath, "GET", "/history", handler.ListHistory, RouteSpec{
		Summary: "获取手动触发历史",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   new(dto.ListManualTriggerLogReq),
		Output:  new(dto.ManualTriggerLogListResp),
		Auth:    true,
	})

	Register(group, doc, groupPath, "POST", "/cancel", handler.CancelTrigger, RouteSpec{
		Summary: "取消手动触发任务",
		Tags:    []string{"轮询管理-手动触发"},
		Input:   new(dto.CancelTriggerReq),
		Output:  nil,
		Auth:    true,
	})
}
