package hero_content_image

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

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

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

var NewHeroContentImagesModule = fx.Options(
	// repository
	fx.Provide(repository.NewHeroContentImagesRepository),

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

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

	// router
	fx.Provide(NewHeroContentImagesRouter),
)

func NewHeroContentImagesRouter(fiber *fiber.App, controller *controller.Controller) *HeroContentImagesRouter {
	return &HeroContentImagesRouter{
		App:        fiber,
		Controller: controller,
	}
}

func (_i *HeroContentImagesRouter) RegisterHeroContentImagesRoutes() {
	imageController := _i.Controller.HeroContentImages

	_i.App.Route("/hero-content-images", func(router fiber.Router) {
		router.Get("/:hero_id", imageController.FindByHeroID)
		router.Post("/", imageController.Save)
		router.Put("/:id", imageController.Update)
		router.Delete("/:id", imageController.Delete)
	})
}