-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcourse.go
64 lines (54 loc) · 1.92 KB
/
course.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
package eduboard
import (
"gopkg.in/mgo.v2/bson"
"time"
)
type Course struct {
ID bson.ObjectId `json:"id,omitempty" bson:"_id"`
Title string `json:"title,omitempty" bson:"title,omitempty"`
Description string `json:"description,omitempty" bson:"description,omitempty"`
Members []string `json:"members,omitempty" bson:"members,omitempty"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
Labels []string `json:"labels" bson:"labels"`
EntryIDs []bson.ObjectId `json:"entryIDs" bson:"entryIDs"`
Entries []CourseEntry `json:"entries" bson:"entries"`
Schedules []Schedule `json:"schedules" bson:"schedules"`
}
type Schedule struct {
Day time.Weekday `json:"day" bson:"day"`
Start time.Time `json:"startsAt" bson:"startsAt"`
Duration time.Duration `json:"duration,omitempty" bson:"duration"`
Room string `json:"room,omitempty" bson:"room"`
Title string `json:"title,omitempty" bson:"title"`
}
type CourseInserter interface {
Insert(course *Course) error
}
type CourseOneFinder interface {
FindOneByID(id string) (error, Course)
}
type CourseManyFinder interface {
FindMany(query bson.M) (error, []Course)
}
type CourseUpdater interface {
Update(id string, update bson.M) (error, Course)
}
type CourseFindUpdater interface {
CourseOneFinder
CourseUpdater
}
type CourseRepository interface {
CourseInserter
CourseOneFinder
CourseManyFinder
CourseUpdater
}
type CourseService interface {
CreateCourse(c *Course) (*Course, error)
GetAllCourses() (err error, courses []Course)
GetCourse(id string, cef CourseEntryManyFinder) (err error, course Course)
GetCoursesByMember(id string, cef CourseEntryManyFinder) (err error, courses []Course)
GetMembers(id string, uF UserFinder) (error, []User)
AddMembers(id string, members []string) (error, Course)
RemoveMembers(id string, members []string) (error, Course)
}