2024-01-28 21:39:32 +00:00
|
|
|
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"
|
|
|
|
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"
|
|
|
|
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
|
|
|
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
|
|
|
benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Services struct {
|
|
|
|
BenefactorSvc benefactorservice.Service
|
|
|
|
BenefactorKindBoxReqSvc benefactorkindboxreqservice.Service
|
|
|
|
BenefactorAddressSvc benefactoraddressservice.Service
|
|
|
|
AdminKindBoxSvc adminkindboxservice.Service
|
|
|
|
AdminSvc adminservice.Service
|
|
|
|
AdminKindBoxReqSvc adminkindboxreqservice.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 {
|
2024-05-17 20:16:28 +00:00
|
|
|
return adminkindboxreqservice.New(InitBenefactorKindBoxReqDB(db), InitAdminKindBoxService(db))
|
2024-01-28 21:39:32 +00:00
|
|
|
}
|