package media_library

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

	"web-qudo-be/app/module/media_library/controller"
	"web-qudo-be/app/module/media_library/repository"
	"web-qudo-be/app/module/media_library/service"
)

type MediaLibraryRouter struct {
	App  *fiber.App
	Ctrl *controller.MediaLibraryController
}

var NewMediaLibraryModule = fx.Options(
	fx.Provide(repository.NewMediaLibraryRepository),
	fx.Provide(service.NewMediaLibraryService),
	fx.Provide(controller.NewMediaLibraryController),
	fx.Provide(NewMediaLibraryRouter),
)

func NewMediaLibraryRouter(app *fiber.App, ctrl *controller.MediaLibraryController) *MediaLibraryRouter {
	return &MediaLibraryRouter{App: app, Ctrl: ctrl}
}

func (r *MediaLibraryRouter) RegisterMediaLibraryRoutes() {
	c := r.Ctrl
	r.App.Route("/media-library", func(router fiber.Router) {
		router.Get("/", c.All)
		router.Post("/register", c.Register)
		router.Post("/upload", c.Upload)
		router.Delete("/:id", c.Delete)
	})
}
