package services

import (
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/accessstat"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/db"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/downloader"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/downloader/strategy"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/metacache"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/mount"
	"gitlink.org.cn/cloudream/jcs-pub/client/internal/uploader"
	"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/distlock"
	"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/sysevent"
)

// Service 结构体封装了分布锁服务和任务管理服务。
type Service struct {
	PubLock          *distlock.Service
	Downloader       *downloader.Downloader
	AccessStat       *accessstat.AccessStat
	Uploader         *uploader.Uploader
	StrategySelector *strategy.Selector
	UserSpaceMeta    *metacache.UserSpaceMeta
	DB               *db.DB
	EvtPub           *sysevent.Publisher
	Mount            *mount.Mount
}

func NewService(
	publock *distlock.Service,
	downloader *downloader.Downloader,
	accStat *accessstat.AccessStat,
	uploder *uploader.Uploader,
	strategySelector *strategy.Selector,
	userSpaceMeta *metacache.UserSpaceMeta,
	db *db.DB,
	evtPub *sysevent.Publisher,
	mount *mount.Mount,
) *Service {
	return &Service{
		PubLock:          publock,
		Downloader:       downloader,
		AccessStat:       accStat,
		Uploader:         uploder,
		StrategySelector: strategySelector,
		UserSpaceMeta:    userSpaceMeta,
		DB:               db,
		EvtPub:           evtPub,
		Mount:            mount,
	}
}
