// 黑豆云商品抓取
package controller

import (
	"github.com/gofiber/fiber/v3"
)

type Controller struct {
}

func NewController() *Controller {
	return &Controller{}
}

func (c *Controller) GetData(ctx fiber.Ctx) error {
	//https://shop.yunmadian.com/shop/manage/goods/edit?goods_id=14479
	productBeanList := hdyColly.StartCrawlProduct(
		"eweishop-user=p2ameerhkfmafgbm9ai5qj38f6; shopId=355; warehose_id=0; storeId=; is_expired=1",
		121,
		187,
	)
	for _, v := range productBeanList {
		productService.SaveProduct(v)
	}

	return ctx.JSON(len(productBeanList))
}

func (c *Controller) PostData(ctx fiber.Ctx) error {
	return ctx.Status(fiber.StatusCreated).SendString("Data saved successfully")
}
