-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
44 lines (39 loc) · 971 Bytes
/
user.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
package userland
import (
"github.com/go-errors/errors"
"time"
)
//User is domain entity
type User struct {
ID int
Email string
Fullname string
Phone string
Location string
Bio string
WebURL string
PictureURL string
Password string
TFAEnabled bool
Verified bool
BackupCodes []string
TFAEnabledAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
var (
//ErrUserNotFound represent user is not found when searching in repository
ErrUserNotFound = errors.New("User not found")
//ErrDuplicateKey represent insert duplicated user
ErrDuplicateKey = errors.New("Duplicate key in user")
)
//UserRepository provide an interface to get user entities
type UserRepository interface {
Find(id int) (User, error)
FindByEmail(email string) (User, error)
Insert(user *User) error
Update(user User) error
// problematic func here
StoreBackupCodes(user User) error
Delete(id int) error
}