package routes

import (
	"github.com/gofiber/fiber/v2"

	"github.com/break/junhong_cmp_fiber/pkg/openapi"
	"github.com/break/junhong_cmp_fiber/pkg/response"
)

type HealthResponse struct {
	Status  string `json:"status" description:"健康状态"`
	Service string `json:"service,omitempty" description:"服务名称"`
}

func registerHealthRoutes(app *fiber.App, doc *openapi.Generator) {
	Register(app, doc, "", "GET", "/health", func(c *fiber.Ctx) error {
		return response.Success(c, fiber.Map{
			"status":  "healthy",
			"service": "junhong_cmp_fiber",
		})
	}, RouteSpec{
		Summary: "健康检查",
		Tags:    []string{"系统"},
		Input:   nil,
		Output:  new(HealthResponse),
		Auth:    false,
	})

	Register(app, doc, "", "GET", "/ready", func(c *fiber.Ctx) error {
		return response.Success(c, fiber.Map{
			"status": "ready",
		})
	}, RouteSpec{
		Summary: "就绪检查",
		Tags:    []string{"系统"},
		Input:   nil,
		Output:  new(HealthResponse),
		Auth:    false,
	})
}
