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

	Register(commission, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
		Summary: "提现申请列表",
		Tags:    []string{"佣金提现审批"},
		Input:   new(dto.WithdrawalRequestListReq),
		Output:  new(dto.WithdrawalRequestPageResult),
		Auth:    true,
	})

	Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/approve", handler.ApproveWithdrawal, RouteSpec{
		Summary: "审批通过提现申请",
		Tags:    []string{"佣金提现审批"},
		Input:   new(dto.ApproveWithdrawalReq),
		Output:  new(dto.WithdrawalApprovalResp),
		Auth:    true,
	})

	Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/reject", handler.RejectWithdrawal, RouteSpec{
		Summary: "拒绝提现申请",
		Tags:    []string{"佣金提现审批"},
		Input:   new(dto.RejectWithdrawalReq),
		Output:  new(dto.WithdrawalApprovalResp),
		Auth:    true,
	})
}

// registerCommissionWithdrawalSettingRoutes 注册提现配置管理路由
func registerCommissionWithdrawalSettingRoutes(router fiber.Router, handler *admin.CommissionWithdrawalSettingHandler, doc *openapi.Generator, basePath string) {
	commission := router.Group("/commission")
	groupPath := basePath + "/commission"

	Register(commission, doc, groupPath, "POST", "/withdrawal-settings", handler.Create, RouteSpec{
		Summary: "新增提现配置",
		Tags:    []string{"提现配置管理"},
		Input:   new(dto.CreateWithdrawalSettingReq),
		Output:  new(dto.WithdrawalSettingItem),
		Auth:    true,
	})

	Register(commission, doc, groupPath, "GET", "/withdrawal-settings", handler.List, RouteSpec{
		Summary: "提现配置列表",
		Tags:    []string{"提现配置管理"},
		Input:   new(dto.WithdrawalSettingListReq),
		Output:  new(dto.WithdrawalSettingPageResult),
		Auth:    true,
	})

	Register(commission, doc, groupPath, "GET", "/withdrawal-settings/current", handler.GetCurrent, RouteSpec{
		Summary: "获取当前生效的提现配置",
		Tags:    []string{"提现配置管理"},
		Input:   nil,
		Output:  new(dto.WithdrawalSettingItem),
		Auth:    true,
	})
}
