-
Notifications
You must be signed in to change notification settings - Fork 325
/
Copy pathuser.go
55 lines (45 loc) · 1.24 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
package users
import (
"time"
"github.com/jinzhu/gorm"
"github.com/qor/media"
"github.com/qor/media/oss"
)
type User struct {
gorm.Model
Email string `form:"email"`
Password string
Name string `form:"name"`
Gender string
Role string
Birthday *time.Time
Balance float32
DefaultBillingAddress uint `form:"default-billing-address"`
DefaultShippingAddress uint `form:"default-shipping-address"`
Addresses []Address
Avatar AvatarImageStorage
// Confirm
ConfirmToken string
Confirmed bool
// Recover
RecoverToken string
RecoverTokenExpiry *time.Time
// Accepts
AcceptPrivate bool `form:"accept-private"`
AcceptLicense bool `form:"accept-license"`
AcceptNews bool `form:"accept-news"`
}
func (user User) DisplayName() string {
return user.Email
}
func (user User) AvailableLocales() []string {
return []string{"en-US", "zh-CN"}
}
type AvatarImageStorage struct{ oss.OSS }
func (AvatarImageStorage) GetSizes() map[string]*media.Size {
return map[string]*media.Size{
"small": {Width: 50, Height: 50},
"middle": {Width: 120, Height: 120},
"big": {Width: 320, Height: 320},
}
}