-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwire.go
48 lines (41 loc) · 1014 Bytes
/
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
//go:build wireinject
package main
import (
"github.com/gin-gonic/gin"
"github.com/google/wire"
"webook/internal/repository"
"webook/internal/repository/cache"
"webook/internal/repository/dao"
"webook/internal/service"
"webook/internal/web"
ijwt "webook/internal/web/jwt"
"webook/ioc"
)
func InitWebServer() *gin.Engine {
wire.Build(
// 第三方依赖
ioc.InitDB, ioc.InitRedis,
ioc.InitLogger,
// Dao 部分
dao.NewUserDAO,
dao.NewArticleGORMDAO,
// cache 部分
cache.NewCodeCache, cache.NewUserCache,
// Repository 部分
repository.NewCachedUserRepository, repository.NewCodeRepository, repository.NewCachedArticleRepository,
// Service 部分
ioc.InitSMSService,
ioc.InitWechatService,
service.NewUserService,
service.NewCodeService,
service.NewArticleService,
// Handler 部分
web.NewUserHandler,
web.NewOAuth2WechatHandler,
ijwt.NewRedisJWTHandler,
web.NewArticleHandler,
ioc.InitGinMiddlewares,
ioc.InitWebServer,
)
return gin.Default()
}