package user_role_accesses

import (
	"narasi-ahli-be/app/module/user_role_accesses/controller"
	"narasi-ahli-be/app/module/user_role_accesses/repository"
	"narasi-ahli-be/app/module/user_role_accesses/service"

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

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

// register bulky of UserRoleAccesses module
var NewUserRoleAccessesModule = fx.Options(
	// register repository of UserRoleAccesses module
	fx.Provide(repository.NewUserRoleAccessesRepository),

	// register service of UserRoleAccesses module
	fx.Provide(service.NewUserRoleAccessesService),

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

	// register router of UserRoleAccesses module
	fx.Provide(NewUserRoleAccessesRouter),
)

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

// register routes of UserRoleAccesses module
func (_i *UserRoleAccessesRouter) RegisterUserRoleAccessesRoutes() {
	// define controllers
	userRoleAccessesController := _i.Controller.UserRoleAccesses

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