package popup_news_contents

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

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

// struct of PopupNewsContentsRouter
type PopupNewsContentsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

// register bulky of PopupNewsContents module
var NewPopupNewsContentsModule = fx.Options(
	// register repository
	fx.Provide(repository.NewPopupNewsContentsRepository),

	// register service
	fx.Provide(service.NewPopupNewsContentsService),

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

	// register router
	fx.Provide(NewPopupNewsContentsRouter),
)

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

// register routes
func (_i *PopupNewsContentsRouter) RegisterPopupNewsContentsRoutes() {
	popupNewsContentsController := _i.Controller.PopupNewsContent

	_i.App.Route("/popup-news-contents", func(router fiber.Router) {
		router.Get("/", popupNewsContentsController.All)
		router.Get("/:id", popupNewsContentsController.Show)
		router.Post("/", popupNewsContentsController.Save)
		router.Put("/:id", popupNewsContentsController.Update)
		router.Delete("/:id", popupNewsContentsController.Delete)
	})
}