package galleries

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

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

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

// NewGalleriesModule register bulky of Galleries module
var NewGalleriesModule = fx.Options(
	// register repository of Galleries module
	fx.Provide(repository.NewGalleriesRepository),

	// register service of Galleries module
	fx.Provide(service.NewGalleriesService),

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

	// register router of Galleries module
	fx.Provide(NewGalleriesRouter),
)

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

// RegisterGalleriesRoutes register routes of Galleries module
func (_i *GalleriesRouter) RegisterGalleriesRoutes() {
	// define controllers
	galleriesController := _i.Controller.Galleries

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

