-
Notifications
You must be signed in to change notification settings - Fork 0
/
wire.go
64 lines (49 loc) · 1.57 KB
/
wire.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
56
57
58
59
60
61
62
63
64
package main
import (
repository "attendance/Repository"
rest_handlers "attendance/RestHandlers"
user_routes "attendance/Router"
services "attendance/Services"
models "attendance/Models"
"fmt"
"github.com/google/wire"
"github.com/jinzhu/gorm"
)
// "fmt"
func DBConnectionProvider() *gorm.DB {
dbURI := "host=localhost user=postgres dbname=postgres sslmode=disable password=prakash port=5432"
var dB *gorm.DB
dB, err = gorm.Open("postgres", dbURI)
if err != nil {
fmt.Println(err.Error())
panic("Cannot connect to Database")
} else {
fmt.Println("Successfully connected to database")
}
// defer DB.Close()
dB.AutoMigrate(&models.Student{})
dB.AutoMigrate(&models.Teacher{})
dB.AutoMigrate(&models.Attendance{})
return dB
}
func InitializeEvent() *AppInterfaceImpl {
wire.Build(
user_routes.NewAppRouterInterfaceImpl,
wire.Bind(new(user_routes.AppRouterInterface), new(*user_routes.AppRouterInterfaceImpl)),
rest_handlers.NewRestHandlerImpl,
wire.Bind(new(rest_handlers.RestHandler), new(*rest_handlers.RestHandlerImpl)),
services.NewTeacherServiceImpl,
wire.Bind(new(services.TeacherService), new(*services.TeacherServiceImpl)),
services.NewStudentServiceImpl,
wire.Bind(new(services.StudentService), new(*services.StudentServiceImpl)),
repository.NewRepoImpl,
wire.Bind(new(repository.Repo), new(*repository.RepoImpl)),
// models.NewModelImpl,
// wire.Bind(new(models.Model), new(models.ModelImpl)),
NewApp,
NewMuxProvider,
DBConnectionProvider,
// wire.Bind(new(AppInterface), new(*AppInterfaceImpl)),
)
return &AppInterfaceImpl{}
}