-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_event.go
49 lines (42 loc) · 1.68 KB
/
log_event.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
package logic
import (
v1 "github.com/klovercloud-ci-cd/event-bank/core/v1"
"github.com/klovercloud-ci-cd/event-bank/core/v1/repository"
"github.com/klovercloud-ci-cd/event-bank/core/v1/service"
"time"
)
type logEventService struct {
repo repository.LogEventRepository
processFootmarkService service.ProcessFootmark
}
func (l logEventService) GetByProcessIdAndStepAndClaim(processId string, step string, claim int, option v1.LogEventQueryOption) ([]v1.LogEvent, int64) {
return l.repo.GetByProcessIdAndStepAndClaim(processId, step, claim, option)
}
func (l logEventService) GetByProcessIdAndStepAndFootmark(processId string, step string, footmark string, cliam int, option v1.LogEventQueryOption) ([]string, int64) {
return l.repo.GetByProcessIdAndStepAndFootmark(processId, step, footmark, cliam, option)
}
func (l logEventService) Store(log v1.LogEvent) {
if log.Log != "" {
l.repo.Store(log)
}
if log.Footmark != "" {
if l.processFootmarkService.GetFootmarkByProcessIdAndStepAndFootmark(log.ProcessId, log.Step, log.Footmark) == nil {
l.processFootmarkService.Store(v1.ProcessFootmark{
ProcessId: log.ProcessId,
Step: log.Step,
Footmark: log.Footmark,
Time: time.Now().UTC(),
})
}
}
}
func (l logEventService) GetByProcessId(processId string, option v1.LogEventQueryOption) ([]string, int64) {
return l.repo.GetByProcessId(processId, option)
}
// NewLogEventService returns LogEvent type service
func NewLogEventService(repo repository.LogEventRepository, processFootmarkService service.ProcessFootmark) service.LogEvent {
return &logEventService{
repo: repo,
processFootmarkService: processFootmarkService,
}
}