package campaign_destinations

import (
	"campaign-pool-be/app/module/campaign_destinations/controller"
	"campaign-pool-be/app/module/campaign_destinations/repository"
	"campaign-pool-be/app/module/campaign_destinations/service"

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

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

// NewCampaignDestinationsModule register bulky of CampaignDestinations module
var NewCampaignDestinationsModule = fx.Options(
	// register repository of CampaignDestinations module
	fx.Provide(repository.NewCampaignDestinationsRepository),

	// register service of CampaignDestinations module
	fx.Provide(service.NewCampaignDestinationsService),

	// register controller of CampaignDestinations module
	fx.Provide(controller.NewController),

	// register router of CampaignDestinations module
	fx.Provide(NewCampaignDestinationsRouter),
)

// NewCampaignDestinationsRouter init CampaignDestinationsRouter
func NewCampaignDestinationsRouter(fiber *fiber.App, controller *controller.Controller) *CampaignDestinationsRouter {
	return &CampaignDestinationsRouter{
		App:        fiber,
		Controller: controller,
	}
}

// RegisterCampaignDestinationsRoutes register routes of CampaignDestinations module
func (_i *CampaignDestinationsRouter) RegisterCampaignDestinationsRoutes() {
	// define controllers
	campaignDestinationsController := _i.Controller.CampaignDestinations

	// define routes
	_i.App.Route("/campaign-destinations", func(router fiber.Router) {
		router.Get("/", campaignDestinationsController.All)
		router.Get("/:id", campaignDestinationsController.Show)
		router.Post("/", campaignDestinationsController.Save)
		router.Put("/:id", campaignDestinationsController.Update)
		router.Delete("/:id", campaignDestinationsController.Delete)
	})
}

