package article_comments

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

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

// register bulky of ArticleComments module
var NewArticleCommentsModule = fx.Options(
	// register repository of ArticleComments module
	fx.Provide(repository.NewArticleCommentsRepository),

	// register service of ArticleComments module
	fx.Provide(service.NewArticleCommentsService),

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

	// register router of ArticleComments module
	fx.Provide(NewArticleCommentsRouter),
)

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

// register routes of ArticleComments module
func (_i *ArticleCommentsRouter) RegisterArticleCommentsRoutes() {
	// define controllers
	articleCommentsController := _i.Controller.ArticleComments

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