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"
)

// registerPollingConcurrencyRoutes 注册轮询并发控制路由
func registerPollingConcurrencyRoutes(router fiber.Router, handler *admin.PollingConcurrencyHandler, doc *openapi.Generator, basePath string) {
	concurrency := router.Group("/polling-concurrency")
	groupPath := basePath + "/polling-concurrency"

	Register(concurrency, doc, groupPath, "GET", "", handler.List, RouteSpec{
		Summary: "获取轮询并发配置列表",
		Tags:    []string{"轮询管理-并发控制"},
		Input:   nil,
		Output:  new(dto.PollingConcurrencyListResp),
		Auth:    true,
	})

	Register(concurrency, doc, groupPath, "POST", "/reset", handler.Reset, RouteSpec{
		Summary: "重置轮询并发计数",
		Tags:    []string{"轮询管理-并发控制"},
		Input:   new(dto.ResetPollingConcurrencyReq),
		Output:  nil,
		Auth:    true,
	})

	Register(concurrency, doc, groupPath, "GET", "/:task_type", handler.Get, RouteSpec{
		Summary: "获取指定任务类型的并发配置",
		Tags:    []string{"轮询管理-并发控制"},
		Input:   new(dto.GetPollingConcurrencyReq),
		Output:  new(dto.PollingConcurrencyResp),
		Auth:    true,
	})

	Register(concurrency, doc, groupPath, "PUT", "/:task_type", handler.Update, RouteSpec{
		Summary: "更新轮询并发配置",
		Tags:    []string{"轮询管理-并发控制"},
		Input:   new(dto.UpdatePollingConcurrencyReq),
		Output:  nil,
		Auth:    true,
	})
}
