package user_roles

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

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

// register bulky of UserRoles module
var NewUserRolesModule = fx.Options(
	// register repository of UserRoles module
	fx.Provide(repository.NewUserRolesRepository),

	// register service of UserRoles module
	fx.Provide(service.NewUserRolesService),

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

	// register router of UserRoles module
	fx.Provide(NewUserRolesRouter),
)

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

// register routes of UserRoles module
func (_i *UserRolesRouter) RegisterUserRolesRoutes() {
	// define controllers
	userRolesController := _i.Controller.UserRoles

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