-
Notifications
You must be signed in to change notification settings - Fork 0
/
ioc.go
45 lines (35 loc) · 961 Bytes
/
ioc.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
package impl
import (
"context"
"gitee.com/go-kade/library/ioc"
"gitee.com/go-kade/library/ioc/config/datasource"
"github.com/kadegolang/sso/app/user/impl"
)
var (
AppName = "token"
)
// 导入这个包的时候,直接把这个对象 UserServiceImpL 注册给IocUserService ioc
// 注册user业务模块(业务模块的名称是user.AppName)的控制器,想要注册需要满足,下面的方法
func init() {
ioc.Default().Registry(&TokenServiceImpl{})
}
func (u *TokenServiceImpl) Init() error {
u.db = datasource.DB(context.Background())
u.user = ioc.Default().Get(impl.AppName).(*impl.UserServiceImpl)
return nil
}
func (u *TokenServiceImpl) Name() string {
return AppName
}
func (u *TokenServiceImpl) Version() string {
return ""
}
func (u *TokenServiceImpl) Priority() int {
return 9
}
func (u *TokenServiceImpl) Close(ctx context.Context) error {
return nil
}
func (u *TokenServiceImpl) AllowOverwrite() bool {
return true
}