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

func registerCarrierRoutes(router fiber.Router, handler *admin.CarrierHandler, doc *openapi.Generator, basePath string) {
	carriers := router.Group("/carriers")
	groupPath := basePath + "/carriers"

	Register(carriers, doc, groupPath, "GET", "", handler.List, RouteSpec{
		Summary: "运营商列表",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.CarrierListRequest),
		Output:  new(dto.CarrierPageResult),
		Auth:    true,
	})

	Register(carriers, doc, groupPath, "POST", "", handler.Create, RouteSpec{
		Summary: "创建运营商",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.CreateCarrierRequest),
		Output:  new(dto.CarrierResponse),
		Auth:    true,
	})

	Register(carriers, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
		Summary: "获取运营商详情",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.IDReq),
		Output:  new(dto.CarrierResponse),
		Auth:    true,
	})

	Register(carriers, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
		Summary: "更新运营商",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.UpdateCarrierParams),
		Output:  new(dto.CarrierResponse),
		Auth:    true,
	})

	Register(carriers, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
		Summary: "删除运营商",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.IDReq),
		Output:  nil,
		Auth:    true,
	})

	Register(carriers, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
		Summary: "更新运营商状态",
		Tags:    []string{"运营商管理"},
		Input:   new(dto.UpdateCarrierStatusParams),
		Output:  nil,
		Auth:    true,
	})
}
