-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwire.go
More file actions
76 lines (66 loc) · 1.97 KB
/
wire.go
File metadata and controls
76 lines (66 loc) · 1.97 KB
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
//go:build wireinject
package main
import (
repository2 "github.com/LEILEI0628/GoWeb/interactive/repository"
cache2 "github.com/LEILEI0628/GoWeb/interactive/repository/cache"
dao2 "github.com/LEILEI0628/GoWeb/interactive/repository/dao"
service2 "github.com/LEILEI0628/GoWeb/interactive/service"
"github.com/LEILEI0628/GoWeb/internal/repository"
articleRepo "github.com/LEILEI0628/GoWeb/internal/repository/article"
"github.com/LEILEI0628/GoWeb/internal/repository/cache"
"github.com/LEILEI0628/GoWeb/internal/repository/dao"
articleDao "github.com/LEILEI0628/GoWeb/internal/repository/dao/article"
"github.com/LEILEI0628/GoWeb/internal/service"
"github.com/LEILEI0628/GoWeb/internal/web"
"github.com/LEILEI0628/GoWeb/internal/web/handler"
"github.com/LEILEI0628/GoWeb/internal/web/router"
"github.com/LEILEI0628/GoWeb/ioc"
"github.com/gin-gonic/gin"
"github.com/google/wire"
)
var interactiveSvcProvider = wire.NewSet(
service2.NewInteractiveService,
repository2.NewCachedInteractiveRepository,
dao2.NewGORMInteractiveDAO,
cache2.NewRedisInteractiveCache,
)
var databaseSelect = wire.NewSet(ioc.InitDB)
type DatabaseType string
var MySQL DatabaseType = "mysql"
func InitWebServer() *gin.Engine {
//database := MySQL
//if database == MySQL {
//
//}
wire.Build(
// 初始化最基础的第三方依赖
//ioc.InitDB,
databaseSelect,
ioc.InitRedis,
// 初始化DAO
dao.NewUserDAO,
articleDao.NewGORMArticleDAO,
// 初始化Cache
cache.NewUserCache,
// 初始化Repository
repository.NewUserRepository,
articleRepo.NewArticleRepository,
// 初始化Service
ioc.InitUserService,
service.NewArticleService,
interactiveSvcProvider,
// 初始化Handler
handler.NewUserHandler,
handler.NewArticleHandler,
// 初始化Routers
router.NewUserRouters,
router.NewArticleRouters,
// 初始化Routers、中间件、server
web.NewRegisterRouters,
ioc.InitLimiter,
ioc.InitGlobalLogger,
ioc.InitMiddleware,
ioc.InitGin,
)
return new(gin.Engine)
}