-
Notifications
You must be signed in to change notification settings - Fork 1
/
controller.go
37 lines (32 loc) · 908 Bytes
/
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
package user
import (
"github.com/svera/coreander/v3/internal/result"
"github.com/svera/coreander/v3/internal/webserver/model"
)
type usersRepository interface {
List(page int, resultsPerPage int) (result.Paginated[[]model.User], error)
Total() int64
FindByUuid(uuid string) (*model.User, error)
FindByUsername(username string) (*model.User, error)
Create(user *model.User) error
Update(user *model.User) error
FindByEmail(email string) (*model.User, error)
Admins() int64
Delete(uuid string) error
}
type Config struct {
MinPasswordLength int
WordsPerMinute float64
Secret []byte
}
type Controller struct {
repository usersRepository
config Config
}
// NewController returns a new instance of the users controller
func NewController(repository usersRepository, usersCfg Config) *Controller {
return &Controller{
repository: repository,
config: usersCfg,
}
}