package admin

import (
	"github.com/gofiber/fiber/v2"

	"github.com/break/junhong_cmp_fiber/internal/model/dto"
	batchPricingService "github.com/break/junhong_cmp_fiber/internal/service/shop_package_batch_pricing"
	"github.com/break/junhong_cmp_fiber/pkg/errors"
	"github.com/break/junhong_cmp_fiber/pkg/response"
)

type ShopPackageBatchPricingHandler struct {
	service *batchPricingService.Service
}

func NewShopPackageBatchPricingHandler(service *batchPricingService.Service) *ShopPackageBatchPricingHandler {
	return &ShopPackageBatchPricingHandler{service: service}
}

// BatchUpdatePricing 批量调价
func (h *ShopPackageBatchPricingHandler) BatchUpdatePricing(c *fiber.Ctx) error {
	var req dto.BatchUpdateCostPriceRequest
	if err := c.BodyParser(&req); err != nil {
		return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
	}

	result, err := h.service.BatchUpdatePricing(c.UserContext(), &req)
	if err != nil {
		return err
	}

	return response.Success(c, result)
}
