package ppid_data_files

import (
	"github.com/gofiber/fiber/v2"
	"go-humas-be/app/module/ppid_data_files/controller"
	"go-humas-be/app/module/ppid_data_files/repository"
	"go-humas-be/app/module/ppid_data_files/service"
	"go.uber.org/fx"
)

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

// register bulky of PpidDataFiles module
var NewPpidDataFilesModule = fx.Options(
	// register repository of PpidDataFiles module
	fx.Provide(repository.NewPpidDataFilesRepository),

	// register service of PpidDataFiles module
	fx.Provide(service.NewPpidDataFilesService),

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

	// register router of PpidDataFiles module
	fx.Provide(NewPpidDataFilesRouter),
)

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

// register routes of PpidDataFiles module
func (_i *PpidDataFilesRouter) RegisterPpidDataFilesRoutes() {
	// define controllers
	ppidDataFilesController := _i.Controller.PpidDataFiles

	// define routes
	_i.App.Route("/ppid-data-files", func(router fiber.Router) {
		router.Get("/", ppidDataFilesController.All)
		router.Get("/:id", ppidDataFilesController.Show)
		router.Post("/:ppidDataId", ppidDataFilesController.Save)
		router.Put("/:id", ppidDataFilesController.Update)
		router.Delete("/:id", ppidDataFilesController.Delete)
		router.Get("/viewer/:filename", ppidDataFilesController.Viewer)
	})
}
