-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
41 lines (32 loc) · 957 Bytes
/
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
package quote
import "context"
type Service interface {
Create(ctx context.Context, q *Quote) error
Update(ctx context.Context, q *Quote) error
Delete(ctx context.Context, id string) error
GetAll(ctx context.Context) ([]Quote, error)
GetById(ctx context.Context, id string) (*Quote, error)
}
type service struct {
repository Repository
}
func NewService(r Repository) Service {
return &service{
repository: r,
}
}
func (s *service) Create(ctx context.Context, q *Quote) error {
return s.repository.Create(ctx, q)
}
func (s *service) Update(ctx context.Context, q *Quote) error {
return s.repository.Update(ctx, q)
}
func (s *service) Delete(ctx context.Context, id string) error {
return s.repository.Delete(ctx, id)
}
func (s *service) GetAll(ctx context.Context) ([]Quote, error) {
return s.repository.GetAll(ctx)
}
func (s *service) GetById(ctx context.Context, id string) (*Quote, error) {
return s.repository.GetById(ctx, id)
}