package user_levels

import (
	"jaecoo-be/app/module/user_levels/controller"
	"jaecoo-be/app/module/user_levels/repository"
	"jaecoo-be/app/module/user_levels/service"

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

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

// register bulky of UserLevels module
var NewUserLevelsModule = fx.Options(
	// register repository of UserLevels module
	fx.Provide(repository.NewUserLevelsRepository),

	// register service of UserLevels module
	fx.Provide(service.NewUserLevelsService),

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

	// register router of UserLevels module
	fx.Provide(NewUserLevelsRouter),
)

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

// register routes of UserLevels module
func (_i *UserLevelsRouter) RegisterUserLevelsRoutes() {
	// define controllers
	userLevelsController := _i.Controller.UserLevels

	// define routes
	_i.App.Route("/user-levels", func(router fiber.Router) {
		router.Get("/", userLevelsController.All)
		router.Get("/:id", userLevelsController.Show)
		router.Get("/alias/:alias", userLevelsController.ShowByAlias)
		router.Post("/", userLevelsController.Save)
		router.Put("/:id", userLevelsController.Update)
		router.Delete("/:id", userLevelsController.Delete)
		router.Put("/approval/:id", userLevelsController.EnableApproval)
	})
}
