niki/internal/initial/validator.go

49 lines
1.9 KiB
Go

package initial
import (
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
"git.gocasts.ir/ebhomengo/niki/config"
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin"
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req"
)
type Validators struct {
BenefactorVld benefactorvalidator.Validator
BenefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator
BenefactorAddressVld benefactoraddressvalidator.Validator
AdminKindBoxReqVld adminkindboxreqvalidator.Validator
AdminVld adminvalidator.Validator
}
func InitAdminKindBoxReqValidator(db *mysql.DB, cfg config.Config) adminkindboxreqvalidator.Validator {
return adminkindboxreqvalidator.New(InitBenefactorKindBoxReqDB(db), InitAdminService(cfg, db))
}
func InitAdminValidator(db *mysql.DB) adminvalidator.Validator {
return adminvalidator.New(InitAdminMysql(db))
}
func InitBenefactorValidator() benefactorvalidator.Validator {
return benefactorvalidator.New()
}
func InitBenefactorKindBoxReqValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorkindboxreqvalidator.Validator {
return benefactorkindboxreqvalidator.New(
InitBenefactorService(cfg, redisAdapter, db),
InitBenefactorAddressService(db),
InitAdminReferTimeService(db),
InitBenefactorKindBoxReqDB(db),
)
}
func InitBenefactorAddressValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactoraddressvalidator.Validator {
return benefactoraddressvalidator.New(
InitBenefactorService(cfg, redisAdapter, db),
InitBenefactorAddressDB(db),
)
}