-
Notifications
You must be signed in to change notification settings - Fork 2
/
repository.go
43 lines (35 loc) · 1.48 KB
/
repository.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
package reservation
import (
"context"
"time"
"github.com/nglogic/go-application-guide/internal/app/bikerental"
)
// Repository provides methods for reading/writing reservation data.
type Repository interface {
// List returns list of reservations matching request criteria.
List(context.Context, ListReservationsQuery) ([]bikerental.Reservation, error)
// Get returns a reservation by id.
// Returns app.ErrNotFound if reservation doesn't exists.
Get(ctx context.Context, id string) (*bikerental.Reservation, error)
// Create creates new reservation for a bike.
// If any reservation for this bike exists within given time range, will return bikerental.ConflictError.
// Returns created reservation data with filled all ids.
Create(context.Context, bikerental.Reservation) (*bikerental.Reservation, error)
// SetStatus updates the status of the reservation by its id.
// Returns app.ErrNotFound if reservation doesn't exists.
SetStatus(ctx context.Context, id string, status bikerental.ReservationStatus) error
}
// ListReservationsQuery is a set of filters for reservations result.
type ListReservationsQuery struct {
BikeID string
StartTime time.Time
EndTime time.Time
Status bikerental.ReservationStatus
Limit int
}
// CustomerRepository provides methods for reading customer data.
type CustomerRepository interface {
// Get returns customer by id.
// Returns app.ErrNotFound if customer doesn't exist.
Get(ctx context.Context, id string) (*bikerental.Customer, error)
}