forked from ebhomengo/niki
1
0
Fork 0
niki/internal/initial/service.go

78 lines
3.2 KiB
Go

package initial
import (
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar"
kavenegarotp "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar/otp"
"git.gocasts.ir/ebhomengo/niki/config"
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
mysqladdress "git.gocasts.ir/ebhomengo/niki/repository/mysql/address"
mysqlbenefactor "git.gocasts.ir/ebhomengo/niki/repository/mysql/benefactor"
mysqlkindbox "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box"
mysqlkindboxreq "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box_req"
redisotp "git.gocasts.ir/ebhomengo/niki/repository/redis/redis_otp"
adminservice "git.gocasts.ir/ebhomengo/niki/service/admin/admin"
adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box"
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
adminrefertimeservice "git.gocasts.ir/ebhomengo/niki/service/admin/refer_time"
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box"
benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req"
)
type Services struct {
BenefactorSvc benefactorservice.Service
BenefactorKindBoxReqSvc benefactorkindboxreqservice.Service
BenefactorAddressSvc benefactoraddressservice.Service
BenefactorKindBoxSvc benefactorkindboxservice.Service
AdminKindBoxSvc adminkindboxservice.Service
AdminSvc adminservice.Service
AdminKindBoxReqSvc adminkindboxreqservice.Service
AdminReferTimeSvc adminrefertimeservice.Service
}
func initSms(cfg config.Config) *kavenegarotp.Adapter {
return kavenegarotp.New(smsprovider.New(cfg.KavenegarSmsProvider))
}
func InitAdminService(cfg config.Config, db *mysql.DB) adminservice.Service {
return adminservice.New(InitAdminMysql(db), InitAdminAuthService(cfg))
}
func InitBenefactorService(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorservice.Service {
return benefactorservice.New(
cfg.BenefactorSvc,
redisotp.New(redisAdapter),
initSms(cfg),
InitBenefactorAuthService(cfg),
mysqlbenefactor.New(db),
)
}
func InitBenefactorAddressService(db *mysql.DB) benefactoraddressservice.Service {
return benefactoraddressservice.New(mysqladdress.New(db))
}
func InitBenefactorKindBoxReqService(db *mysql.DB) benefactorkindboxreqservice.Service {
return benefactorkindboxreqservice.New(mysqlkindboxreq.New(db))
}
func InitAdminKindBoxService(db *mysql.DB) adminkindboxservice.Service {
return adminkindboxservice.New(InitKindBoxRepo(db))
}
func InitAdminKindBoxReqService(db *mysql.DB) adminkindboxreqservice.Service {
return adminkindboxreqservice.New(InitBenefactorKindBoxReqDB(db), InitAdminKindBoxService(db))
}
func InitAdminReferTimeService(db *mysql.DB) adminrefertimeservice.Service {
return adminrefertimeservice.New(
InitAdminReferTimeDB(db),
)
}
func InitBenefactorKindBoxService(db *mysql.DB) benefactorkindboxservice.Service {
return benefactorkindboxservice.New(mysqlkindbox.New(db))
}