-
Notifications
You must be signed in to change notification settings - Fork 1
/
controller.go
48 lines (41 loc) · 1.43 KB
/
controller.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
package highlight
import (
"github.com/svera/coreander/v3/internal/index"
"github.com/svera/coreander/v3/internal/result"
"github.com/svera/coreander/v3/internal/webserver/model"
)
type highlightsRepository interface {
Highlights(userID int, page int, resultsPerPage int) (result.Paginated[[]string], error)
Highlight(userID int, documentPath string) error
Remove(userID int, documentPath string) error
Highlighted(userID int, documents index.Document) index.Document
}
// IdxReaderWriter defines a set of reading and writing operations over an index
type IdxReaderWriter interface {
Document(Slug string) (index.Document, error)
Documents(IDs []string) (map[string]index.Document, error)
}
type usersRepository interface {
FindByUuid(uuid string) (*model.User, error)
FindByUsername(username string) (*model.User, error)
}
type Sender interface {
SendDocument(address string, libraryPath string, fileName string) error
From() string
}
type Controller struct {
hlRepository highlightsRepository
usrRepository usersRepository
idx IdxReaderWriter
sender Sender
wordsPerMinute float64
}
func NewController(hlRepository highlightsRepository, usrRepository usersRepository, sender Sender, wordsPerMinute float64, idx IdxReaderWriter) *Controller {
return &Controller{
hlRepository: hlRepository,
usrRepository: usrRepository,
idx: idx,
sender: sender,
wordsPerMinute: wordsPerMinute,
}
}