/
model.go
49 lines (38 loc) · 1014 Bytes
/
model.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
package imports
import (
"context"
"time"
"github.com/bobinette/papernet/errors"
)
var (
ErrNotFound = errors.New("paper not found")
)
type Paper struct {
ID int `json:"id"`
Source string `json:"source"`
Reference string `json:"reference"`
Title string `json:"title"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
Authors []string `json:"authors"`
References []string `json:"references"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Repository interface {
Save(userID, paperID int, source, ref string) error
Get(userID int, source, ref string) (int, error)
}
type Pagination struct {
Limit uint `json:"limit"`
Offset uint `json:"offset"`
Total uint `json:"total"`
}
type SearchResults struct {
Papers []Paper `json:"papers"`
Pagination Pagination `json:"pagination"`
}
type Searcher interface {
Source() string
Search(ctx context.Context, q string, limit, offset int) (SearchResults, error)
}