package admin

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

func SetupRoutes(r *gin.RouterGroup) {
	SetupDashboardRoutes(r)
	SetupApplicationRoutes(r)
	SetupCardRoutes(r)
	SetupUserRoutes(r)
	SetupDeviceRoutes(r)
	SetupFinanceRoutes(r)
	SetupLogRoutes(r)
	SetupTicketRoutes(r)
	SetupAgentAppRoutes(r)
	SetupAgentsRoutes(r)
	SetupCloudRoutes(r)
	SetupDynamicRoutes(r)
	SetupExtensionRoutes(r)
	SetupOrderRoutes(r)
	SetupUsageRoutes(r)
	SetupAnnouncementRoutes(r)
	SetupVersionRoutes(r)
	SetupProfileRoutes(r)
	SetupEmailRoutes(r)
	SetupSystemSettingsRoutes(r)
	SetupEmailConfigRoutes(r)
	SetupSmsConfigRoutes(r)
	SetupStorageConfigRoutes(r)
}

func SetupRoutesWithoutPackage(r *gin.RouterGroup) {
	SetupAgentAppRoutesWithoutPackage(r)
	SetupCardRoutesWithoutPackage(r)
}

func SetupExtensionRoutes(r *gin.RouterGroup) {
	extension := r.Group("/extension")
	{
		// Webhook配置
		extension.GET("/webhooks", handleGetWebhooks)
		extension.POST("/webhooks", handleCreateWebhook)
		extension.PUT("/webhooks/:id", handleUpdateWebhook)
		extension.PUT("/webhooks/:id/status", handleUpdateWebhookStatus)
		extension.DELETE("/webhooks/:id", handleDeleteWebhook)
		extension.PUT("/webhooks/batch/status", handleBatchUpdateWebhookStatus)
		extension.DELETE("/webhooks/batch", handleBatchDeleteWebhooks)
		extension.GET("/webhooks/logs", handleGetWebhookLogs)
		extension.POST("/webhooks/:id/test", handleTestWebhook)

		// API密钥
		extension.GET("/api-keys", handleGetAPIKeys)
		extension.POST("/api-keys", handleCreateAPIKey)
		extension.PUT("/api-keys/:id", handleUpdateAPIKey)
		extension.PUT("/api-keys/:id/status", handleUpdateAPIKeyStatus)
		extension.DELETE("/api-keys/:id", handleDeleteAPIKey)
		extension.PUT("/api-keys/batch/status", handleBatchUpdateAPIKeyStatus)
		extension.DELETE("/api-keys/batch", handleBatchDeleteAPIKeys)
		extension.POST("/api-keys/:id/regenerate", handleRegenerateAPIKey)
	}
}
