package routes

import (
	"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"
	"github.com/gofiber/fiber/v2"
)

func registerAdminExchangeRoutes(router fiber.Router, handler *admin.ExchangeHandler, doc *openapi.Generator, basePath string) {
	Register(router, doc, basePath, "POST", "/exchanges", handler.Create, RouteSpec{
		Summary: "创建换货单",
		Tags:    []string{"换货管理"},
		Input:   new(dto.CreateExchangeRequest),
		Output:  new(dto.ExchangeOrderResponse),
		Auth:    true,
	})

	Register(router, doc, basePath, "GET", "/exchanges", handler.List, RouteSpec{
		Summary: "获取换货单列表",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeListRequest),
		Output:  new(dto.ExchangeListResponse),
		Auth:    true,
	})

	Register(router, doc, basePath, "GET", "/exchanges/:id", handler.Get, RouteSpec{
		Summary: "获取换货单详情",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeIDRequest),
		Output:  new(dto.ExchangeOrderResponse),
		Auth:    true,
	})

	Register(router, doc, basePath, "POST", "/exchanges/:id/ship", handler.Ship, RouteSpec{
		Summary: "换货发货",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeShipParams),
		Output:  new(dto.ExchangeOrderResponse),
		Auth:    true,
	})

	Register(router, doc, basePath, "POST", "/exchanges/:id/complete", handler.Complete, RouteSpec{
		Summary: "确认换货完成",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeIDRequest),
		Output:  nil,
		Auth:    true,
	})

	Register(router, doc, basePath, "POST", "/exchanges/:id/cancel", handler.Cancel, RouteSpec{
		Summary: "取消换货",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeCancelParams),
		Output:  nil,
		Auth:    true,
	})

	Register(router, doc, basePath, "POST", "/exchanges/:id/renew", handler.Renew, RouteSpec{
		Summary: "旧资产转新",
		Tags:    []string{"换货管理"},
		Input:   new(dto.ExchangeIDRequest),
		Output:  nil,
		Auth:    true,
	})
}
