-
Notifications
You must be signed in to change notification settings - Fork 1
/
people.go
53 lines (42 loc) · 1.34 KB
/
people.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
package models
import (
"database/sql/driver"
"time"
"github.com/flanksource/duty/types"
"github.com/google/uuid"
)
type Person struct {
ID uuid.UUID `json:"id" gorm:"default:generate_ulid()"`
Name string `json:"name"`
Email string `json:"email,omitempty" gorm:"default:null"`
Type string `json:"type,omitempty" gorm:"default:null"`
Avatar string `json:"avatar,omitempty" gorm:"default:null"`
ExternalID string `json:"external_id,omitempty" gorm:"default:null"`
Properties PersonProperties `json:"properties,omitempty" gorm:"default:null"`
}
func (person Person) TableName() string {
return "people"
}
func (person Person) AsMap(removeFields ...string) map[string]any {
return asMap(person, removeFields...)
}
type PersonProperties struct {
Role string `json:"role,omitempty"`
}
func (p PersonProperties) Value() (driver.Value, error) {
return types.GenericStructValue(p, true)
}
func (p *PersonProperties) Scan(val any) error {
return types.GenericStructScan(&p, val)
}
type AccessToken struct {
ID uuid.UUID `gorm:"default:generate_ulid()"`
Name string `gorm:"not null"`
Value string `gorm:"not null"`
PersonID uuid.UUID
ExpiresAt time.Time
CreatedAt time.Time
}
func (AccessToken) TableName() string {
return "access_tokens"
}