-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_management.go
83 lines (71 loc) · 1.91 KB
/
app_management.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
package logics
import (
"main/common"
"main/logics/dependency"
"main/logics/proxy"
"main/models"
"sync"
)
type AppManagementService interface {
RegisterApp(req *models.PostAppReqVO) (res *models.PostAppResVO, err error)
GetAppList(req *models.GetAppReqVO) (res *models.GetAppResVO, err error)
UpdateApp(req *models.PutAppByIdReqVO) (err error)
GetAppConfigs() (res *models.GetAppConfigResVO, err error)
ToggleAppSwitch(req *models.PutAppByIdSwitchReqVO) (err error)
CancelApp(req *models.DeleteAppByIdReqVO) (err error)
}
var (
amSvc AppManagementService
amSvcOnce sync.Once
)
type appManagementService struct {
repo dependency.AppManagementRepo
eventLoop common.EventLoop
}
func NewAppManagementService() AppManagementService {
amSvcOnce.Do(func() {
svc := &appManagementService{
repo: dependency.GetAppManagementRepo(),
eventLoop: common.GetEventLoop(common.Channel),
}
svc.init()
amSvc = svc
proxy.InjectAppManagementService(amSvc)
})
return amSvc
}
func (s *appManagementService) init() {
s.eventLoop.AddListener("clear_app", func(payload any) (err error) {
for _, key := range payload.([]uint64) {
err = s.CancelApp(&models.DeleteAppByIdReqVO{ID: int(key)})
if err != nil {
return
}
}
return
})
}
func (s *appManagementService) RegisterApp(req *models.PostAppReqVO) (res *models.PostAppResVO, err error) {
//...
return
}
func (s *appManagementService) GetAppList(req *models.GetAppReqVO) (res *models.GetAppResVO, err error) {
//...
return
}
func (s *appManagementService) UpdateApp(req *models.PutAppByIdReqVO) (err error) {
//...
return
}
func (s *appManagementService) GetAppConfigs() (res *models.GetAppConfigResVO, err error) {
//...
return
}
func (s *appManagementService) ToggleAppSwitch(req *models.PutAppByIdSwitchReqVO) (err error) {
//...
return
}
func (s *appManagementService) CancelApp(req *models.DeleteAppByIdReqVO) (err error) {
//...
return
}