package user_role_level_details

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

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

// register bulky of UserRoleLevelDetails module
var NewUserRoleLevelDetailsModule = fx.Options(
	// register repository of UserRoleLevelDetails module
	fx.Provide(repository.NewUserRoleLevelDetailsRepository),

	// register service of UserRoleLevelDetails module
	fx.Provide(service.NewUserRoleLevelDetailsService),

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

	// register router of UserRoleLevelDetails module
	fx.Provide(NewUserRoleLevelDetailsRouter),
)

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

// register routes of UserRoleLevelDetails module
func (_i *UserRoleLevelDetailsRouter) RegisterUserRoleLevelDetailsRoutes() {
	// define controllers
	userRoleLevelDetailsController := _i.Controller.UserRoleLevelDetails

	// define routes
	_i.App.Route("/user-role-level-details", func(router fiber.Router) {
		router.Get("/", userRoleLevelDetailsController.All)
		router.Get("/:id", userRoleLevelDetailsController.Show)
		router.Post("/", userRoleLevelDetailsController.Save)
		router.Put("/:id", userRoleLevelDetailsController.Update)
		router.Delete("/:id", userRoleLevelDetailsController.Delete)
	})
}
