package article_category_details

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

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

// register bulky of ArticleCategoryDetails module
var NewArticleCategoryDetailsModule = fx.Options(
	// register repository of ArticleCategoryDetails module
	fx.Provide(repository.NewArticleCategoryDetailsRepository),

	// register service of ArticleCategoryDetails module
	fx.Provide(service.NewArticleCategoryDetailsService),

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

	// register router of ArticleCategoryDetails module
	fx.Provide(NewArticleCategoryDetailsRouter),
)

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

// register routes of ArticleCategoryDetails module
func (_i *ArticleCategoryDetailsRouter) RegisterArticleCategoryDetailsRoutes() {
	// define controllers
	articleCategoryDetailsController := _i.Controller.ArticleCategoryDetails

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