-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
80 lines (67 loc) · 2.06 KB
/
types.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
package meta
import (
"errors"
"time"
)
type Service interface {
GetRoleRequirementForGuild(action string, gid string) (string, error)
IGNService
EventService
ParticipationService
}
type IGNService interface {
CreateIGN(userID, ign string) error
GetIGN(userID string) (string, error)
ListAllIGN() (map[string]string, error)
UpdateIGN(userID, newIGN string) error
DeleteRelation(userID string) error
}
type EventService interface {
CreateEvent(
name, eventType string,
start, end time.Time,
gid string,
active bool,
) (string, error)
UpdateEvent(id, name, eventType string, start, end time.Time, gid string, active bool) error
SetEventStatus(id string, status bool) error
SetEventEndDate(id string, end time.Time) error
GetEvent(id string) (*Event, error)
ListAllEvent() ([]*Event, error)
ListEventsForGuild(gid string) ([]*Event, error)
ListActiveEventsForGuild(gid string) ([]*Event, error)
DeleteEvent(id string) error
}
type ParticipationService interface {
AddParticipation(userID, eventID string, participating bool) (string, error)
DeleteParticipation(id string) error
DeleteParticipationByUserAndEvent(uid, eid string) error
ListUserForEvent(eid string) (map[string]string, map[string]string, error)
UserInEvent(uid, eid string) (bool, error)
SetParticipation(id string, status bool) error
SetParticipationByUserAndEvent(uid, eid string, status bool) error
GetParticipation(uid, eid string) (string, bool, error)
}
type Event struct {
ID string `db:"id"`
GID string `db:"guild_id"`
Name string `db:"name"`
Begin time.Time `db:"start_date"`
End time.Time `db:"end_date"`
Active bool `db:"active"`
EventType string `db:"event_type"`
}
var _ error = &ErrNoRecord{}
type ErrNoRecord struct{}
func (e *ErrNoRecord) Error() string {
return "no records found"
}
func AsErrNoRecord(e error) bool {
nr := &ErrNoRecord{}
return errors.As(e, &nr)
}
var _ error = &ErrDuplicateEntry{}
type ErrDuplicateEntry struct{ M string }
func (e *ErrDuplicateEntry) Error() string {
return "duplicate entry: " + e.M
}