package ppid_data_categories

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

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

// register bulky of PpidDataCategories module
var NewPpidDataCategoriesModule = fx.Options(
	// register repository of PpidDataCategories module
	fx.Provide(repository.NewPpidDataCategoriesRepository),

	// register service of PpidDataCategories module
	fx.Provide(service.NewPpidDataCategoriesService),

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

	// register router of PpidDataCategories module
	fx.Provide(NewPpidDataCategoriesRouter),
)

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

// register routes of PpidDataCategories module
func (_i *PpidDataCategoriesRouter) RegisterPpidDataCategoriesRoutes() {
	// define controllers
	ppidDataCategoriesController := _i.Controller.PpidDataCategories

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