package admin

import (
	"bindbox-game/internal/pkg/logger"
	"bindbox-game/internal/repository/mysql"
	"bindbox-game/internal/repository/mysql/dao"
	activitysvc "bindbox-game/internal/service/activity"
	adminsvc "bindbox-game/internal/service/admin"
	bannersvc "bindbox-game/internal/service/banner"
	channelsvc "bindbox-game/internal/service/channel"
	productsvc "bindbox-game/internal/service/product"
	syscfgsvc "bindbox-game/internal/service/sysconfig"
	titlesvc "bindbox-game/internal/service/title"
	usersvc "bindbox-game/internal/service/user"
)

type handler struct {
	logger   logger.CustomLogger
	writeDB  *dao.Query
	readDB   *dao.Query
	repo     mysql.Repo
	svc      adminsvc.Service
	activity activitysvc.Service
	product  productsvc.Service
	user     usersvc.Service
	banner   bannersvc.Service
	channel  channelsvc.Service
	title    titlesvc.Service
	syscfg   syscfgsvc.Service
}

func New(logger logger.CustomLogger, db mysql.Repo) *handler {
	return &handler{
		logger:   logger,
		writeDB:  dao.Use(db.GetDbW()),
		readDB:   dao.Use(db.GetDbR()),
		repo:     db,
		svc:      adminsvc.New(logger, db),
		activity: activitysvc.New(logger, db),
		product:  productsvc.New(logger, db),
		user:     usersvc.New(logger, db),
		banner:   bannersvc.New(logger, db),
		channel:  channelsvc.New(logger, db),
		title:    titlesvc.New(logger, db),
		syscfg:   syscfgsvc.New(logger, db),
	}
}
