-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.go
55 lines (47 loc) · 1.93 KB
/
all.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package all
import (
"github.com/masudur-rahman/pawsitively-purrfect/infra/database/nosql"
isql "github.com/masudur-rahman/pawsitively-purrfect/infra/database/sql"
"github.com/masudur-rahman/pawsitively-purrfect/infra/logr"
"github.com/masudur-rahman/pawsitively-purrfect/repos/pet"
"github.com/masudur-rahman/pawsitively-purrfect/repos/pet_adoption"
"github.com/masudur-rahman/pawsitively-purrfect/repos/shelter"
"github.com/masudur-rahman/pawsitively-purrfect/repos/user"
"github.com/masudur-rahman/pawsitively-purrfect/services"
petsvc "github.com/masudur-rahman/pawsitively-purrfect/services/pet"
sheltersvc "github.com/masudur-rahman/pawsitively-purrfect/services/shelter"
usersvc "github.com/masudur-rahman/pawsitively-purrfect/services/user"
)
type Services struct {
User services.UserService
Pet services.PetService
Shelter services.ShelterService
}
func GetNoSQLServices(db nosql.Database, logger logr.Logger) *Services {
userRepo := user.NewNoSQLUserRepository(db, logger)
petRepo := pet.NewNoSQLPetRepository(db, logger)
paRepo := pet_adoption.NewNoSQLPetAdoptionRepository(db, logger)
shelterRepo := shelter.NewNoSQLShelterRepository(db, logger)
userSvc := usersvc.NewUserService(userRepo)
petSvc := petsvc.NewPetService(petRepo, userRepo, paRepo)
shelterSvc := sheltersvc.NewShelterService(shelterRepo)
return &Services{
User: userSvc,
Pet: petSvc,
Shelter: shelterSvc,
}
}
func GetSQLServices(db isql.Database, logger logr.Logger) *Services {
userRepo := user.NewSQLUserRepository(db, logger)
petRepo := pet.NewSQLPetRepository(db, logger)
paRepo := pet_adoption.NewSQLPetAdoptionRepository(db, logger)
shelterRepo := shelter.NewSQLShelterRepository(db, logger)
userSvc := usersvc.NewUserService(userRepo)
petSvc := petsvc.NewPetService(petRepo, userRepo, paRepo)
shelterSvc := sheltersvc.NewShelterService(shelterRepo)
return &Services{
User: userSvc,
Pet: petSvc,
Shelter: shelterSvc,
}
}