-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
55 lines (35 loc) · 1.09 KB
/
module.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
package sm
import (
"errors"
)
type Module struct {
ID int64
Name string
Description string
ApiKey string
Enabled bool
}
type ModuleRepository interface {
CreateModule(module *Module) error
IsNameInUse(name string) (bool, error)
SetAvailability(id int64, enabled bool) error
GetModules(modules *[]map[string]interface{}) error
GetModulesOBJ(modules *[]*Module) error
GetModuleByKey(api_key string) (*Module, error)
GetModuleByID(id int64) (*Module, error)
GenerateApiKey(module_name string) string
Save(module *Module) error
}
// errors
var ErrServiceNameTooShort = errors.New("Name is too short")
var ErrServiceDescTooShort = errors.New("Desc is too short")
var ErrServiceNameInUse = errors.New("Name is in use")
// services
type ModuleService interface {
CreateService(name, description string) (*Module, error)
UpdateName(id int64, name string) error
UpdateDescription(id int64, description string) error
Update(id int64, name string, description string) error
SetAvailability(id int64, enable bool) error
RenewApiKey(id int64) (*Module, error)
}