/
user.go
30 lines (25 loc) · 835 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
package model
import "github.com/jinzhu/gorm"
// User represents a user in both gorm and json worlds
type User struct {
gorm.Model
UserID string `gorm:"not null" json:"userId"`
Name string `gorm:"" json:"name"`
Email string `gorm:"not null" json:"email"`
Address string `gorm:"" json:"address"`
Roles []Role `gorm:"many2many:user_roles" json:"roles"`
// Ease front end and JSON communication, not persisted
UserRoles []string `gorm:"-" json:"userRoles"`
Meta map[string]interface{} `gorm:"-" json:"meta"`
}
// Role is used to manage permissions
type Role struct {
RoleID string `gorm:"primary_key" json:"roleId"`
Label string `gorm:"" json:"label"`
}
// Group might be a user or a role
type Group struct {
ID string `json:"id"`
Label string `json:"label"`
Type string `json:"type"`
}