package appconfig

import (
	"hyapp-admin-server/internal/middleware"

	"github.com/gin-gonic/gin"
)

func RegisterRoutes(protected *gin.RouterGroup, h *Handler) {
	if h == nil {
		return
	}

	protected.GET("/admin/app-config/h5-links", middleware.RequirePermission("app-config:view"), h.ListH5Links)
	protected.POST("/admin/app-config/h5-links", middleware.RequirePermission("app-config:update"), h.CreateH5Link)
	protected.PUT("/admin/app-config/h5-links", middleware.RequirePermission("app-config:update"), h.UpdateH5Links)
	protected.PUT("/admin/app-config/h5-links/:key", middleware.RequirePermission("app-config:update"), h.UpdateH5Link)
	protected.DELETE("/admin/app-config/h5-links/:key", middleware.RequirePermission("app-config:update"), h.DeleteH5Link)
	protected.GET("/admin/app-config/gift", middleware.RequirePermission("app-config:view"), h.GetGiftConfig)
	protected.PUT("/admin/app-config/gift", middleware.RequirePermission("app-config:update"), h.UpdateGiftConfig)
	protected.GET("/admin/app-config/gift-combo", middleware.RequirePermission("app-config:view"), h.GetGiftComboConfig)
	protected.PUT("/admin/app-config/gift-combo", middleware.RequirePermission("app-config:update"), h.UpdateGiftComboConfig)
	protected.GET("/admin/app-config/floating-screen", middleware.RequirePermission("app-config:view"), h.GetFloatingScreenConfig)
	protected.PUT("/admin/app-config/floating-screen", middleware.RequirePermission("app-config:update"), h.UpdateFloatingScreenConfig)
	protected.GET("/admin/app-config/room-discovery", middleware.RequirePermission("app-config:view"), h.GetRoomDiscoveryConfig)
	protected.PUT("/admin/app-config/room-discovery", middleware.RequirePermission("app-config:update"), h.UpdateRoomDiscoveryConfig)
	protected.GET("/admin/app-config/runtime-capabilities", middleware.RequirePermission("app-config:view"), h.GetRuntimeCapabilitiesConfig)
	protected.PUT("/admin/app-config/runtime-capabilities", middleware.RequirePermission("app-config:update"), h.UpdateRuntimeCapabilitiesConfig)
	protected.GET("/admin/app-config/role-scope-policies", middleware.RequirePermission("app-config:view"), h.GetRoleScopePoliciesConfig)
	protected.PUT("/admin/app-config/role-scope-policies", middleware.RequirePermission("app-config:update"), h.UpdateRoleScopePoliciesConfig)

	protected.GET("/admin/app-config/explore-tabs", middleware.RequirePermission("app-config:view"), h.ListExploreTabs)
	protected.POST("/admin/app-config/explore-tabs", middleware.RequirePermission("app-config:update"), h.CreateExploreTab)
	protected.PUT("/admin/app-config/explore-tabs/:tab_id", middleware.RequirePermission("app-config:update"), h.UpdateExploreTab)
	protected.DELETE("/admin/app-config/explore-tabs/:tab_id", middleware.RequirePermission("app-config:update"), h.DeleteExploreTab)

	protected.GET("/admin/app-config/banners", middleware.RequirePermission("app-config:view"), h.ListBanners)
	protected.POST("/admin/app-config/banners", middleware.RequirePermission("app-config:update"), h.CreateBanner)
	protected.PUT("/admin/app-config/banners/:banner_id", middleware.RequirePermission("app-config:update"), h.UpdateBanner)
	protected.DELETE("/admin/app-config/banners/:banner_id", middleware.RequirePermission("app-config:update"), h.DeleteBanner)

	protected.GET("/admin/app-config/splash-screens", middleware.RequirePermission("app-config:view"), h.ListSplashScreens)
	protected.POST("/admin/app-config/splash-screens", middleware.RequirePermission("app-config:update"), h.CreateSplashScreen)
	protected.PUT("/admin/app-config/splash-screens/:splash_id", middleware.RequirePermission("app-config:update"), h.UpdateSplashScreen)
	protected.DELETE("/admin/app-config/splash-screens/:splash_id", middleware.RequirePermission("app-config:update"), h.DeleteSplashScreen)

	protected.GET("/admin/app-config/popups", middleware.RequirePermission("app-config:view"), h.ListPopups)
	protected.POST("/admin/app-config/popups", middleware.RequirePermission("app-config:update"), h.CreatePopup)
	protected.PUT("/admin/app-config/popups/:popup_id", middleware.RequirePermission("app-config:update"), h.UpdatePopup)
	protected.DELETE("/admin/app-config/popups/:popup_id", middleware.RequirePermission("app-config:update"), h.DeletePopup)

	protected.GET("/admin/app-config/versions", middleware.RequirePermission("app-version:view"), h.ListAppVersions)
	protected.POST("/admin/app-config/versions", middleware.RequirePermission("app-version:create"), h.CreateAppVersion)
	protected.PUT("/admin/app-config/versions/:version_id", middleware.RequirePermission("app-version:update"), h.UpdateAppVersion)
	protected.DELETE("/admin/app-config/versions/:version_id", middleware.RequirePermission("app-version:delete"), h.DeleteAppVersion)
}
