package initialize

import (
	"gitea.pena/SQuiz/core/internal/brokers"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/account"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/question"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/quiz"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/result"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/statistic"
	"gitea.pena/SQuiz/core/internal/controllers/http_controllers/telegram"
	"gitea.pena/SQuiz/core/internal/controllers/rpc_controllers"
	"github.com/go-redis/redis/v8"
)

type ControllerDeps struct {
	Clients     *Clients
	DALs        *DALs
	Config      Config
	Producer    brokers.IProducer
	RedisClient *redis.Client
}

type Controller struct {
	GRpcControllers GRpcControllers
	HttpControllers HttpControllers
}

type GRpcControllers struct {
	MailNotify *rpc_controllers.MailNotify
}
type HttpControllers struct {
	Account   *account.Account
	Question  *question.Question
	Quiz      *quiz.Quiz
	Result    *result.Result
	Statistic *statistic.Statistic
	Telegram  *telegram.Telegram
}

func NewControllers(deps ControllerDeps) *Controller {
	return &Controller{
		GRpcControllers: GRpcControllers{
			MailNotify: rpc_controllers.NewMailNotify(deps.DALs.PgDAL),
		},
		HttpControllers: HttpControllers{
			Account: account.NewAccountController(account.Deps{
				Dal:         deps.DALs.PgDAL,
				AuthClient:  deps.Clients.AuthClient,
				Producer:    deps.Producer,
				ServiceName: deps.Config.ServiceName,
				RedisClient: deps.RedisClient,
			}),
			Question: question.NewQuestionController(question.Deps{
				DAL: deps.DALs.PgDAL,
			}),
			Quiz: quiz.NewQuizController(quiz.Deps{
				DAL: deps.DALs.PgDAL,
			}),
			Result: result.NewResultController(result.Deps{
				DAL:      deps.DALs.PgDAL,
				S3Prefix: deps.Config.S3Prefix,
			}),
			Statistic: statistic.NewStatisticController(statistic.Deps{
				DAL:   deps.DALs.PgDAL,
				ChDAL: deps.DALs.ChDAL,
			}),
			Telegram: telegram.NewTelegramController(telegram.Deps{
				DAL: deps.DALs.PgDAL,
				//TelegramClient: deps.Clients.TgClient,
			}),
		},
	}
}
