-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
51 lines (43 loc) · 1.34 KB
/
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
42
43
44
45
46
47
48
49
50
51
package rsvp
import (
"context"
"time"
"github.com/faris-arifiansyah/fws-rsvp/enumeration"
"github.com/globalsign/mgo/bson"
)
// Parameter is a struct to simplify passing parameter into function
type Parameter struct {
Sort string
Limit int
Offset int
}
// RsvpResult is a struct container to put result
type RsvpResult struct {
Data []*Rsvp
Total int64
}
// Rsvp Entity
type Rsvp struct {
ID bson.ObjectId `json:"-" bson:"_id,omitempty"`
Name string `json:"name,required" bson:"name"`
Address string `json:"address,required" bson:"address"`
Attend enumeration.AttendanceType `json:"attend" bson:"attend"`
Message string `json:"message" bson:"message"`
CreatedAt time.Time `json:"created_at" bson:"created_at"`
}
//File represents file
type File struct {
Content []byte
Name string
}
// RsvpRepo provides data interchange between
// application and data provider.
type RsvpRepo interface {
CreateRsvp(ctx context.Context, rp Rsvp) (Rsvp, error)
GetRsvps(ctx context.Context, p *Parameter) (*RsvpResult, error)
}
type Usecase interface {
CreateRsvp(ctx context.Context, rp Rsvp) (Rsvp, error)
GetRsvps(ctx context.Context, p *Parameter) (*RsvpResult, error)
WriteRsvpsCsv(ctx context.Context, p *Parameter) (*File, error)
}