package api

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

	"oci-portal/internal/service"
)

// registerSettings 挂载 /settings/* 与 /about,以及系统日志与代理管理。
func registerSettings(secured *gin.RouterGroup, settings *service.SettingService, notifier *service.Notifier, systemLogs *service.SystemLogService, proxies *service.ProxyService) {
	secured.GET("/about", about)
	secured.GET("/system-logs", (&systemLogHandler{svc: systemLogs}).list)

	st := &settingsHandler{svc: settings, notifier: notifier}
	secured.GET("/settings/telegram", st.getTelegram)
	secured.PUT("/settings/telegram", st.updateTelegram)
	secured.POST("/settings/telegram/test", st.testTelegram)
	secured.GET("/settings/notify-channels", st.listNotifyChannels)
	secured.PUT("/settings/notify-channels/:type", st.updateNotifyChannel)
	secured.POST("/settings/notify-channels/:type/test", st.testNotifyChannel)
	secured.GET("/settings/notify-events", st.getNotifyEvents)
	secured.PUT("/settings/notify-events", st.updateNotifyEvents)
	secured.GET("/settings/notify-templates", st.listNotifyTemplates)
	secured.PUT("/settings/notify-templates/:kind", st.updateNotifyTemplate)
	secured.POST("/settings/notify-templates/:kind/test", st.testNotifyTemplate)
	secured.GET("/settings/task", st.getTaskSettings)
	secured.PUT("/settings/task", st.updateTaskSettings)
	secured.GET("/settings/security", st.getSecurity)
	secured.PUT("/settings/security", st.updateSecurity)

	px := &proxyHandler{svc: proxies}
	secured.GET("/proxies", px.list)
	secured.POST("/proxies", px.create)
	secured.POST("/proxies/import", px.importBatch)
	secured.PUT("/proxies/:id", px.update)
	secured.DELETE("/proxies/:id", px.remove)
	secured.POST("/proxies/:id/probe", px.probe)
	secured.PUT("/proxies/:id/tenants", px.setTenants)
}
