-
Notifications
You must be signed in to change notification settings - Fork 9
/
action_type_service.go
41 lines (31 loc) · 1.13 KB
/
action_type_service.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
package service
import (
"errors"
"github.com/IceWhaleTech/CasaOS-MessageBus/model"
"github.com/IceWhaleTech/CasaOS-MessageBus/repository"
)
type ActionTypeService struct {
repository *repository.Repository
}
var (
ErrActionSourceIDNotFound = errors.New("event source id not found")
ErrActionNameNotFound = errors.New("event name not found")
)
func (s *ActionTypeService) GetActionTypes() ([]model.ActionType, error) {
return (*s.repository).GetActionTypes()
}
func (s *ActionTypeService) RegisterActionType(actionType model.ActionType) (*model.ActionType, error) {
// TODO - ensure sourceID and name are URL safe
return (*s.repository).RegisterActionType(actionType)
}
func (s *ActionTypeService) GetActionTypesBySourceID(sourceID string) ([]model.ActionType, error) {
return (*s.repository).GetActionTypesBySourceID(sourceID)
}
func (s *ActionTypeService) GetActionType(sourceID string, name string) (*model.ActionType, error) {
return (*s.repository).GetActionType(sourceID, name)
}
func NewActionTypeService(repository *repository.Repository) *ActionTypeService {
return &ActionTypeService{
repository: repository,
}
}