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 registerPackageRoutes(router fiber.Router, handler *admin.PackageHandler, doc *openapi.Generator, basePath string) {
	packages := router.Group("/packages")
	groupPath := basePath + "/packages"

	Register(packages, doc, groupPath, "GET", "", handler.List, RouteSpec{
		Summary: "套餐列表",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.PackageListRequest),
		Output:  new(dto.PackagePageResult),
		Auth:    true,
	})

	Register(packages, doc, groupPath, "POST", "", handler.Create, RouteSpec{
		Summary: "创建套餐",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.CreatePackageRequest),
		Output:  new(dto.PackageResponse),
		Auth:    true,
	})

	Register(packages, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
		Summary: "获取套餐详情",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.IDReq),
		Output:  new(dto.PackageResponse),
		Auth:    true,
	})

	Register(packages, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
		Summary: "更新套餐",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.UpdatePackageParams),
		Output:  new(dto.PackageResponse),
		Auth:    true,
	})

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

	Register(packages, doc, groupPath, "PATCH", "/:id/status", handler.UpdateStatus, RouteSpec{
		Summary: "更新套餐状态",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.UpdatePackageStatusParams),
		Output:  nil,
		Auth:    true,
	})

	Register(packages, doc, groupPath, "PATCH", "/:id/shelf", handler.UpdateShelfStatus, RouteSpec{
		Summary: "更新套餐上架状态",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.UpdatePackageShelfStatusParams),
		Output:  nil,
		Auth:    true,
	})

	Register(packages, doc, groupPath, "PATCH", "/:id/retail-price", handler.UpdateRetailPrice, RouteSpec{
		Summary: "修改零售价（代理）",
		Tags:    []string{"套餐管理"},
		Input:   new(dto.UpdateRetailPriceParams),
		Output:  nil,
		Auth:    true,
	})
}
