package router

import (
	"kra/internal/server/handler"
	platformmodule "kra/pkg/module"

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

type Routes struct {
	handlers *handler.Set
}

func NewRoutes(handlers *handler.Set) *Routes { return &Routes{handlers: handlers} }

var _ platformmodule.RouteRegistrar = (*Routes)(nil)

func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.Engine) {
	if r == nil || r.handlers == nil {
		return
	}
	registrations := []func(){
		func() { RegisterPublic(public, engine, r.handlers.Public) },
		func() { RegisterUser(private, r.handlers.User) },
		func() { RegisterNavigation(private, r.handlers.Navigation) },
		func() { RegisterSession(private, r.handlers.Session) },
		func() { RegisterAuthority(private, r.handlers.Authority) },
		func() { RegisterMenu(private, r.handlers.Menu) },
		func() { RegisterAPI(private, public, engine, r.handlers.API) },
		func() { RegisterPermission(private, r.handlers.Permission) },
		func() { RegisterOrganization(private, r.handlers.Organization) },
		func() { RegisterDictionary(private, r.handlers.Dictionary) },
		func() { RegisterParameter(private, r.handlers.Parameter) },
		func() { RegisterAPIToken(private, r.handlers.APIToken) },
		func() { RegisterSystemConfig(private, r.handlers.SystemConfig) },
		func() { RegisterVersion(private, r.handlers.Version) },
		func() { RegisterExport(private, public, r.handlers.Export) },
		func() { RegisterAudit(private, public, r.handlers.Audit) },
		func() { RegisterTask(private, r.handlers.Task) },
		func() { RegisterMedia(private, r.handlers.Media) },
		func() { RegisterAnnouncement(private, public, r.handlers.Announcement) },
		func() { RegisterEmail(private, r.handlers.Email) },
		func() { RegisterIntegrationConfig(private, r.handlers.IntegrationConfig) },
		func() { RegisterPayment(private, public, r.handlers.Payment) },
	}
	for _, register := range registrations {
		register()
	}
}
