package server

import (
	"ai_scheduler/internal/gateway"
	"ai_scheduler/internal/server/router"
	"ai_scheduler/internal/services"
	"ai_scheduler/internal/services/advice"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/logger"
	"github.com/gofiber/fiber/v2/middleware/recover"
)

func NewHTTPServer(
	service *services.ChatService,
	session *services.SessionService,
	task *services.TaskService,
	gateway *gateway.Gateway,
	callback *services.CallbackService,
	chatHis *services.HistoryService,
	capabilityService *services.CapabilityService,
	adviceFile *advice.FileService,
	adviceData *advice.AdvicerService,
	adviceChat *advice.ChatService,
	adviceProject *advice.ProjectService,
	adviceTalkSkill *advice.TalkSkillService,
	adviceClient *advice.ClientService,
) *fiber.App {
	//构建 server
	app := initRoute()
	router.SetupRoutes(app, service, session, task, gateway, callback, chatHis, capabilityService, adviceFile, adviceData, adviceChat, adviceProject, adviceTalkSkill, adviceClient)
	return app
}

func initRoute() *fiber.App {
	app := fiber.New()
	app.Use(
		recover.New(),
		logger.New(),
	)
	return app
}
