-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
184 lines (143 loc) · 7.74 KB
/
main.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package main
import (
"e-complaint-api/config"
dashboard_cl "e-complaint-api/controllers/dashboard"
"e-complaint-api/controllers/news_comment"
"e-complaint-api/controllers/news_like"
"e-complaint-api/drivers/mailtrap"
"e-complaint-api/drivers/mysql"
dashboard_repo "e-complaint-api/drivers/mysql/dashboard"
"e-complaint-api/drivers/openai_api"
"e-complaint-api/routes"
dashboard_uc "e-complaint-api/usecases/dashboard"
"os"
gcs_api "e-complaint-api/drivers/google_cloud_storage"
admin_cl "e-complaint-api/controllers/admin"
admin_rp "e-complaint-api/drivers/mysql/admin"
admin_uc "e-complaint-api/usecases/admin"
complaint_cl "e-complaint-api/controllers/complaint"
complaint_rp "e-complaint-api/drivers/mysql/complaint"
complaint_uc "e-complaint-api/usecases/complaint"
complaint_file_rp "e-complaint-api/drivers/mysql/complaint_file"
complaint_file_uc "e-complaint-api/usecases/complaint_file"
complaint_process_cl "e-complaint-api/controllers/complaint_process"
complaint_process_rp "e-complaint-api/drivers/mysql/complaint_process"
complaint_process_uc "e-complaint-api/usecases/complaint_process"
user_cl "e-complaint-api/controllers/user"
user_rp "e-complaint-api/drivers/mysql/user"
user_uc "e-complaint-api/usecases/user"
category_cl "e-complaint-api/controllers/category"
category_rp "e-complaint-api/drivers/mysql/category"
category_uc "e-complaint-api/usecases/category"
discussion_cl "e-complaint-api/controllers/discussion"
discussion_rp "e-complaint-api/drivers/mysql/discussion"
discussion_uc "e-complaint-api/usecases/discussion"
regency_cl "e-complaint-api/controllers/regency"
regency_rp "e-complaint-api/drivers/mysql/regency"
regency_uc "e-complaint-api/usecases/regency"
news_cl "e-complaint-api/controllers/news"
news_rp "e-complaint-api/drivers/mysql/news"
news_uc "e-complaint-api/usecases/news"
news_file_rp "e-complaint-api/drivers/mysql/news_file"
news_file_uc "e-complaint-api/usecases/news_file"
complaint_like "e-complaint-api/controllers/complaint_like"
complaint_like_rp "e-complaint-api/drivers/mysql/complaint_like"
complaint_like_uc "e-complaint-api/usecases/complaint_like"
complaint_activity "e-complaint-api/controllers/complaint_activity"
complaint_activity_rp "e-complaint-api/drivers/mysql/complaint_activity"
complaint_activity_uc "e-complaint-api/usecases/complaint_activity"
chatbot_cl "e-complaint-api/controllers/chatbot"
chatbot_rp "e-complaint-api/drivers/mysql/chatbot"
chatbot_uc "e-complaint-api/usecases/chatbot"
faq_rp "e-complaint-api/drivers/mysql/faq"
news_like_rp "e-complaint-api/drivers/mysql/news_like"
news_like_uc "e-complaint-api/usecases/news_like"
news_comment_rp "e-complaint-api/drivers/mysql/news_comment"
news_comment_uc "e-complaint-api/usecases/news_comment"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
// For local development only
// config.LoadEnv()
config.InitConfigMySQL()
DB := mysql.ConnectDB(config.InitConfigMySQL())
e := echo.New()
e.Use(middleware.CORS())
adminRepo := admin_rp.NewAdminRepo(DB)
adminUsecase := admin_uc.NewAdminUseCase(adminRepo)
AdminController := admin_cl.NewAdminController(adminUsecase)
mailTrapApi := mailtrap.NewMailTrapApi(
os.Getenv("SMTP_HOST"),
os.Getenv("SMTP_PORT"),
os.Getenv("SMTP_USERNAME"),
os.Getenv("SMTP_PASSWORD"),
os.Getenv("SMTP_FROM"),
)
userGCSAPI := gcs_api.NewFileHandlingAPI(os.Getenv("GCS_CREDENTIALS"), "profile-photos/")
userRepo := user_rp.NewUserRepo(DB)
userUsecase := user_uc.NewUserUseCase(userRepo, mailTrapApi, userGCSAPI)
UserController := user_cl.NewUserController(userUsecase)
complaintFileGCSAPI := gcs_api.NewFileHandlingAPI(os.Getenv("GCS_CREDENTIALS"), "complaint-files/")
complaintFileRepo := complaint_file_rp.NewComplaintFileRepo(DB)
complaintFileUsecase := complaint_file_uc.NewComplaintFileUseCase(complaintFileRepo, complaintFileGCSAPI)
complaintRepo := complaint_rp.NewComplaintRepo(DB)
complaintProcessRepo := complaint_process_rp.NewComplaintProcessRepo(DB)
complaintUsecase := complaint_uc.NewComplaintUseCase(complaintRepo, complaintFileRepo)
complaintProcessUsecase := complaint_process_uc.NewComplaintProcessUseCase(complaintProcessRepo, complaintRepo)
ComplaintController := complaint_cl.NewComplaintController(complaintUsecase, complaintFileUsecase, complaintProcessUsecase)
ComplaintProcessController := complaint_process_cl.NewComplaintProcessController(complaintUsecase, complaintProcessUsecase)
categoryRepo := category_rp.NewCategoryRepo(DB)
categoryUsecase := category_uc.NewCategoryUseCase(categoryRepo)
CategoryController := category_cl.NewCategoryController(categoryUsecase)
regencyRepo := regency_rp.NewRegencyRepo(DB)
regencyUsecase := regency_uc.NewRegencyUseCase(regencyRepo)
RegencyController := regency_cl.NewRegencyController(regencyUsecase)
NewsFileGCSAPIInterface := gcs_api.NewFileHandlingAPI(os.Getenv("GCS_CREDENTIALS"), "news-files/")
NewsFileRepo := news_file_rp.NewNewsFileRepo(DB)
NewsFileUsecase := news_file_uc.NewNewsFileUseCase(NewsFileRepo, NewsFileGCSAPIInterface)
newsRepo := news_rp.NewNewsRepo(DB)
newsUsecase := news_uc.NewNewsUseCase(newsRepo)
NewsController := news_cl.NewNewsController(newsUsecase, NewsFileUsecase)
complaintActivityRepo := complaint_activity_rp.NewComplaintActivityRepo(DB)
complaintActivityUsecase := complaint_activity_uc.NewComplaintActivityUseCase(complaintActivityRepo)
ComplaintActivityController := complaint_activity.NewComplaintActivityController(complaintActivityUsecase, complaintUsecase)
openAIAPI := openai_api.NewOpenAIAPI(os.Getenv("OPENAI_API_KEY"))
faqRepo := faq_rp.NewFaqRepo(DB)
discussionRepo := discussion_rp.NewDiscussionRepo(DB)
discussionUsecase := discussion_uc.NewDiscussionUseCase(discussionRepo, faqRepo, openAIAPI)
DiscussionController := discussion_cl.NewDiscussionController(discussionUsecase, complaintUsecase, complaintActivityUsecase)
complaintLikeRepo := complaint_like_rp.NewComplaintLikeRepository(DB)
complaintLikeUsecase := complaint_like_uc.NewComplaintLikeUseCase(complaintLikeRepo)
ComplaintLikeController := complaint_like.NewComplaintLikeController(complaintLikeUsecase, complaintUsecase, complaintActivityUsecase)
chatbotRepo := chatbot_rp.NewChatbotRepo(DB)
chatbotUsecase := chatbot_uc.NewChatbotUseCase(chatbotRepo, faqRepo, complaintRepo, openAIAPI)
ChatbotController := chatbot_cl.NewChatbotController(chatbotUsecase)
newsLikeRepo := news_like_rp.NewNewsLikeRepo(DB)
newsLikeUsecase := news_like_uc.NewNewsLikeUseCase(newsLikeRepo)
NewsLikeController := news_like.NewNewsLikeController(newsLikeUsecase, newsUsecase)
newsCommentRepo := news_comment_rp.NewNewsComment(DB)
newsCommentUsecase := news_comment_uc.NewNewsCommentUseCase(newsCommentRepo)
NewsCommentController := news_comment.NewNewsCommentController(newsCommentUsecase, newsUsecase)
dashboardRepo := dashboard_repo.NewDashboardRepo(DB)
dashboardUsecase := dashboard_uc.NewDashboardUseCase(dashboardRepo)
dashboardController := dashboard_cl.NewDashboardController(*dashboardUsecase)
routes := routes.RouteController{
AdminController: AdminController,
UserController: UserController,
ComplaintController: ComplaintController,
CategoryController: CategoryController,
ComplaintProcessController: ComplaintProcessController,
DiscussionController: DiscussionController,
NewsController: NewsController,
RegencyController: RegencyController,
ComplaintLikeController: ComplaintLikeController,
NewsLikeController: NewsLikeController,
NewsCommentController: NewsCommentController,
ComplaintActivityController: ComplaintActivityController,
ChatbotController: ChatbotController,
DashboardController: dashboardController,
}
routes.InitRoute(e)
e.Start(":8000")
}