package our_product_contents

import (
	"web-qudo-be/app/module/our_product_contents/controller"
	"web-qudo-be/app/module/our_product_contents/repository"
	"web-qudo-be/app/module/our_product_contents/service"

	"github.com/gofiber/fiber/v2"
	"go.uber.org/fx"
)

type OurProductContentsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

var NewOurProductContentsModule = fx.Options(
	// repository
	fx.Provide(repository.NewOurProductContentRepository),

	// service
	fx.Provide(service.NewOurProductContentService),

	// controller
	fx.Provide(controller.NewController),

	// router
	fx.Provide(NewOurProductContentsRouter),
)

// init router
func NewOurProductContentsRouter(fiber *fiber.App, controller *controller.Controller) *OurProductContentsRouter {
	return &OurProductContentsRouter{
		App:        fiber,
		Controller: controller,
	}
}

func (_i *OurProductContentsRouter) RegisterOurProductContentsRoutes() {
	contentController := _i.Controller.OurProductContent

	_i.App.Route("/our-product-contents", func(router fiber.Router) {
		router.Get("/", contentController.Show)
		router.Post("/", contentController.Save)
		router.Put("/:id", contentController.Update)
		router.Delete("/:id", contentController.Delete)
	})
}