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

	Register(shops, doc, groupPath, "GET", "", handler.List, RouteSpec{
		Summary: "店铺列表",
		Tags:    []string{"店铺管理"},
		Input:   new(dto.ShopListRequest),
		Output:  new(dto.ShopPageResult),
		Auth:    true,
	})

	Register(shops, doc, groupPath, "POST", "", handler.Create, RouteSpec{
		Summary: "创建店铺",
		Tags:    []string{"店铺管理"},
		Input:   new(dto.CreateShopRequest),
		Output:  new(dto.ShopResponse),
		Auth:    true,
	})

	Register(shops, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
		Summary: "更新店铺",
		Tags:    []string{"店铺管理"},
		Input:   new(dto.UpdateShopParams),
		Output:  new(dto.ShopResponse),
		Auth:    true,
	})

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

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

	Register(shops, doc, groupPath, "GET", "/commission-summary", handler.ListCommissionSummary, RouteSpec{
		Summary: "代理商佣金列表",
		Tags:    []string{"代理商佣金管理"},
		Input:   new(dto.ShopCommissionSummaryListReq),
		Output:  new(dto.ShopCommissionSummaryPageResult),
		Auth:    true,
	})

	Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
		Summary: "代理商提现记录",
		Tags:    []string{"代理商佣金管理"},
		Input:   new(dto.ShopWithdrawalRequestListReq),
		Output:  new(dto.ShopWithdrawalRequestPageResult),
		Auth:    true,
	})

	Register(shops, doc, groupPath, "GET", "/:shop_id/commission-records", handler.ListCommissionRecords, RouteSpec{
		Summary: "代理商佣金明细",
		Tags:    []string{"代理商佣金管理"},
		Input:   new(dto.ShopCommissionRecordListReq),
		Output:  new(dto.ShopCommissionRecordPageResult),
		Auth:    true,
	})
}
