-
Notifications
You must be signed in to change notification settings - Fork 0
/
whatson.go
66 lines (53 loc) · 1.65 KB
/
whatson.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
package whatson
import (
"context"
"time"
"github.com/jmoiron/sqlx"
"gopkg.in/guregu/null.v4"
)
type (
// Store stores the dependencies
Store struct {
db *sqlx.DB
}
// WhatsOn represents relevant whatsOn fields
WhatsOn struct {
ID int `db:"id" json:"id"`
Title string `db:"title" json:"title"`
FileName null.String `db:"file_name" json:"file_name"`
Content null.String `db:"content" json:"content"`
Date time.Time `db:"date" json:"date"`
DateOfEvent time.Time `db:"date_of_event" json:"date_of_event"`
}
)
// NewWhatsOnRepo stores our dependency
func NewWhatsOnRepo(db *sqlx.DB) *Store {
return &Store{
db: db,
}
}
func (s *Store) GetWhatsOn(ctx context.Context) ([]WhatsOn, error) {
return s.getWhatsOn(ctx)
}
func (s *Store) GetWhatsOnFuture(ctx context.Context) ([]WhatsOn, error) {
return s.getWhatsOnFuture(ctx)
}
func (s *Store) GetWhatsOnPast(ctx context.Context) ([]WhatsOn, error) {
return s.getWhatsOnPast(ctx)
}
func (s *Store) GetWhatsOnLatest(ctx context.Context) (WhatsOn, error) {
return s.getWhatsOnLatest(ctx)
}
func (s *Store) GetWhatsOnArticle(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error) {
return s.getWhatsOnArticle(ctx, whatsOnParam)
}
func (s *Store) AddWhatsOn(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error) {
whatsOnParam.Date = time.Now()
return s.addWhatsOn(ctx, whatsOnParam)
}
func (s *Store) EditWhatsOn(ctx context.Context, whatsOnParam WhatsOn) (WhatsOn, error) {
return s.editWhatsOn(ctx, whatsOnParam)
}
func (s *Store) DeleteWhatsOn(ctx context.Context, whatsOnParam WhatsOn) error {
return s.deleteWhatsOn(ctx, whatsOnParam)
}