package article_nulis_ai

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

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

// register bulky of ArticleNulisAI module
var NewArticleNulisAIModule = fx.Options(
	// register repository of ArticleNulisAI module
	fx.Provide(repository.NewArticleNulisAIRepository),

	// register service of ArticleNulisAI module
	fx.Provide(service.NewArticleNulisAIService),

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

	// register router of ArticleNulisAI module
	fx.Provide(NewArticleNulisAIRouter),
)

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

// register routes of ArticleNulisAI module
func (_i *ArticleNulisAIRouter) RegisterArticleNulisAIRoutes() {
	// define controllers
	articleNulisAIController := _i.Controller.ArticleNulisAI

	// define routes
	_i.App.Route("/article-nulis-ai", func(router fiber.Router) {
		router.Get("/", articleNulisAIController.All)
		router.Get("/:id", articleNulisAIController.Show)
		router.Post("/", articleNulisAIController.Save)
		router.Post("/publish", articleNulisAIController.Publish)
		router.Put("/:id", articleNulisAIController.Update)
		router.Delete("/:id", articleNulisAIController.Delete)
	})
}
