package our_service_contents

import (
	"web-qudo-be/app/module/our_service_contents/controller"
	"web-qudo-be/app/module/our_service_contents/repository"
	"web-qudo-be/app/module/our_service_contents/service"

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

type OurServiceContentsRouter struct {
	App        fiber.Router
	Controller *controller.Controller
}

var NewOurServiceContentsModule = fx.Options(
	// repository
	fx.Provide(repository.NewOurServiceContentRepository),

	// service
	fx.Provide(service.NewOurServiceContentService),

	// controller
	fx.Provide(controller.NewController),

	// router
	fx.Provide(NewOurServiceContentsRouter),
)

// init router
func NewOurServiceContentsRouter(fiber *fiber.App, controller *controller.Controller) *OurServiceContentsRouter {
	return &OurServiceContentsRouter{
		App:        fiber,
		Controller: controller,
	}
}

func (_i *OurServiceContentsRouter) RegisterOurServiceContentsRoutes() {
	contentController := _i.Controller.OurServiceContent

	_i.App.Route("/our-service-contents", func(router fiber.Router) {
		router.Get("/", contentController.Show)
		router.Post("/", contentController.Save)
		router.Put("/:id", contentController.Update)
		router.Delete("/:id", contentController.Delete)
	})
}