package campaign_files

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

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

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

// NewCampaignFilesModule register bulky of CampaignFiles module
var NewCampaignFilesModule = fx.Options(
	// register repository of CampaignFiles module
	fx.Provide(repository.NewCampaignFilesRepository),

	// register service of CampaignFiles module
	fx.Provide(service.NewCampaignFilesService),

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

	// register router of CampaignFiles module
	fx.Provide(NewCampaignFilesRouter),
)

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

// RegisterCampaignFilesRoutes register routes of CampaignFiles module
func (_i *CampaignFilesRouter) RegisterCampaignFilesRoutes() {
	// define controllers
	campaignFilesController := _i.Controller.CampaignFiles

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

