package router

import (
	swagger "github.com/arsmn/fiber-swagger/v2"
	"github.com/gofiber/fiber/v2"
	"go-humas-be/app/module/article_categories"
	"go-humas-be/app/module/article_category_details"
	"go-humas-be/app/module/article_files"
	"go-humas-be/app/module/articles"
	"go-humas-be/app/module/cities"
	"go-humas-be/app/module/districts"
	"go-humas-be/app/module/magazine_files"
	"go-humas-be/app/module/magazines"
	"go-humas-be/app/module/master_menus"
	"go-humas-be/app/module/master_modules"
	"go-humas-be/app/module/ppid_data_categories"
	"go-humas-be/app/module/ppid_data_files"
	"go-humas-be/app/module/ppid_datas"
	"go-humas-be/app/module/provinces"
	"go-humas-be/app/module/user_levels"
	"go-humas-be/app/module/user_role_accesses"
	"go-humas-be/app/module/user_roles"
	"go-humas-be/app/module/users"
	"go-humas-be/config/config"
	_ "go-humas-be/docs/swagger"
)

type Router struct {
	App fiber.Router
	Cfg *config.Config

	ArticleCategoriesRouter      *article_categories.ArticleCategoriesRouter
	ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter
	ArticleFilesRouter           *article_files.ArticleFilesRouter
	ArticlesRouter               *articles.ArticlesRouter
	CitiesRouter                 *cities.CitiesRouter
	DistrictsRouter              *districts.DistrictsRouter
	MagazineFilesRouter          *magazine_files.MagazineFilesRouter
	MagazinesRouter              *magazines.MagazinesRouter
	MasterMenusRouter            *master_menus.MasterMenusRouter
	MasterModulesRouter          *master_modules.MasterModulesRouter
	PpidDataCategoriesRouter     *ppid_data_categories.PpidDataCategoriesRouter
	PpidDataFilesRouter          *ppid_data_files.PpidDataFilesRouter
	PpidDatas                    *ppid_datas.PpidDatasRouter
	ProvincesRouter              *provinces.ProvincesRouter
	UserLevelsRouter             *user_levels.UserLevelsRouter
	UserRoleAccessesRouter       *user_role_accesses.UserRoleAccessesRouter
	UserRolesRouter              *user_roles.UserRolesRouter
	UsersRouter                  *users.UsersRouter
}

func NewRouter(
	fiber *fiber.App,
	cfg *config.Config,

	articleCategoriesRouter *article_categories.ArticleCategoriesRouter,
	articleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter,
	articleFilesRouter *article_files.ArticleFilesRouter,
	articlesRouter *articles.ArticlesRouter,
	citiesRouter *cities.CitiesRouter,
	districtsRouter *districts.DistrictsRouter,
	magazineFilesRouter *magazine_files.MagazineFilesRouter,
	magazinesRouter *magazines.MagazinesRouter,
	masterMenuRouter *master_menus.MasterMenusRouter,
	masterModuleRouter *master_modules.MasterModulesRouter,
	ppidDataCategoriesRouter *ppid_data_categories.PpidDataCategoriesRouter,
	ppidDataFilesRouter *ppid_data_files.PpidDataFilesRouter,
	ppidDatas *ppid_datas.PpidDatasRouter,
	provincesRouter *provinces.ProvincesRouter,
	userLevelsRouter *user_levels.UserLevelsRouter,
	userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter,
	userRolesRouter *user_roles.UserRolesRouter,
	usersRouter *users.UsersRouter,
) *Router {
	return &Router{
		App:                          fiber,
		Cfg:                          cfg,
		ArticleCategoriesRouter:      articleCategoriesRouter,
		ArticleCategoryDetailsRouter: articleCategoryDetailsRouter,
		ArticleFilesRouter:           articleFilesRouter,
		ArticlesRouter:               articlesRouter,
		CitiesRouter:                 citiesRouter,
		DistrictsRouter:              districtsRouter,
		MagazineFilesRouter:          magazineFilesRouter,
		MagazinesRouter:              magazinesRouter,
		MasterMenusRouter:            masterMenuRouter,
		MasterModulesRouter:          masterModuleRouter,
		PpidDataCategoriesRouter:     ppidDataCategoriesRouter,
		PpidDataFilesRouter:          ppidDataFilesRouter,
		PpidDatas:                    ppidDatas,
		ProvincesRouter:              provincesRouter,
		UserLevelsRouter:             userLevelsRouter,
		UserRoleAccessesRouter:       userRoleAccessesRouter,
		UserRolesRouter:              userRolesRouter,
		UsersRouter:                  usersRouter,
	}
}

// Register routes
func (r *Router) Register() {
	// Test Routes
	r.App.Get("/ping", func(c *fiber.Ctx) error {
		return c.SendString("Pong! 👋")
	})

	//Swagger Documentation
	r.App.Get("/swagger/*", swagger.HandlerDefault)

	// Register routes of modules
	r.ArticleCategoriesRouter.RegisterArticleCategoriesRoutes()
	r.ArticleCategoryDetailsRouter.RegisterArticleCategoryDetailsRoutes()
	r.ArticleFilesRouter.RegisterArticleFilesRoutes()
	r.ArticlesRouter.RegisterArticlesRoutes()
	r.CitiesRouter.RegisterCitiesRoutes()
	r.DistrictsRouter.RegisterDistrictsRoutes()
	r.MagazinesRouter.RegisterMagazinesRoutes()
	r.MagazineFilesRouter.RegisterMagazineFilesRoutes()
	r.MasterMenusRouter.RegisterMasterMenusRoutes()
	r.MasterModulesRouter.RegisterMasterModulesRoutes()
	r.PpidDataCategoriesRouter.RegisterPpidDataCategoriesRoutes()
	r.PpidDataFilesRouter.RegisterPpidDataFilesRoutes()
	r.PpidDatas.RegisterPpidDatasRoutes()
	r.ProvincesRouter.RegisterProvincesRoutes()
	r.UserLevelsRouter.RegisterUserLevelsRoutes()
	r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes()
	r.UsersRouter.RegisterUsersRoutes()
	r.UserRolesRouter.RegisterUserRolesRoutes()
}
