package gallery_files

import (
	"jaecoo-be/app/module/gallery_files/controller"
	"jaecoo-be/app/module/gallery_files/repository"
	"jaecoo-be/app/module/gallery_files/service"

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

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

// NewGalleryFilesModule register bulky of GalleryFiles module
var NewGalleryFilesModule = fx.Options(
	// register repository of GalleryFiles module
	fx.Provide(repository.NewGalleryFilesRepository),

	// register service of GalleryFiles module
	fx.Provide(service.NewGalleryFilesService),

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

	// register router of GalleryFiles module
	fx.Provide(NewGalleryFilesRouter),
)

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

// RegisterGalleryFilesRoutes register routes of GalleryFiles module
func (_i *GalleryFilesRouter) RegisterGalleryFilesRoutes() {
	// define controllers
	galleryFilesController := _i.Controller.GalleryFiles

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

