🗃️ Update modeling
This commit is contained in:
@ -2,11 +2,11 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/datatypes"
|
||||
"time"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
@ -21,6 +21,12 @@ type Account struct {
|
||||
SuspendedAt *time.Time `json:"suspended_at"`
|
||||
PermNodes datatypes.JSONMap `json:"perm_nodes"`
|
||||
|
||||
AutomatedBy *Account `json:"automated_by" gorm:"foreignKey:AutomatedID"`
|
||||
AutomatedID *uint `json:"automated_id"`
|
||||
|
||||
AffiliatedTo *Realm `json:"affiliated_to" gorm:"foreignKey:AffiliatedID"`
|
||||
AffiliatedID *uint `json:"affiliated_id"`
|
||||
|
||||
Profile AccountProfile `json:"profile,omitempty"`
|
||||
Contacts []AccountContact `json:"contacts,omitempty"`
|
||||
Badges []Badge `json:"badges,omitempty"`
|
||||
@ -28,11 +34,6 @@ type Account struct {
|
||||
Tickets []AuthTicket `json:"tickets,omitempty"`
|
||||
Factors []AuthFactor `json:"factors,omitempty"`
|
||||
|
||||
Events []ActionEvent `json:"events,omitempty"`
|
||||
|
||||
Notifications []Notification `json:"notifications,omitempty"`
|
||||
NotifySubscribers []NotificationSubscriber `json:"notify_subscribers,omitempty"`
|
||||
|
||||
Relations []AccountRelationship `json:"relations,omitempty" gorm:"foreignKey:AccountID"`
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,11 @@ const (
|
||||
type AuthFactor struct {
|
||||
BaseModel
|
||||
|
||||
Type int8 `json:"type"`
|
||||
Secret string `json:"-"`
|
||||
Config JSONMap `json:"config"`
|
||||
Type int8 `json:"type"`
|
||||
Secret string `json:"-"`
|
||||
Config JSONMap `json:"config"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
||||
@ -41,7 +43,11 @@ type AuthTicket struct {
|
||||
LastGrantAt *time.Time `json:"last_grant_at"`
|
||||
Nonce *string `json:"nonce"`
|
||||
ClientID *uint `json:"client_id"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
||||
IsApiKey bool `json:"is_api_key"`
|
||||
}
|
||||
|
||||
func (v AuthTicket) IsAvailable() error {
|
||||
|
@ -8,5 +8,7 @@ type ActionEvent struct {
|
||||
Location string `json:"location"`
|
||||
IpAddress string `json:"ip_address"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
@ -7,15 +7,17 @@ import (
|
||||
type Notification struct {
|
||||
BaseModel
|
||||
|
||||
Topic string `json:"topic"`
|
||||
Title string `json:"title"`
|
||||
Subtitle *string `json:"subtitle"`
|
||||
Body string `json:"body"`
|
||||
Metadata datatypes.JSONMap `json:"metadata"`
|
||||
Avatar *string `json:"avatar"`
|
||||
Picture *string `json:"picture"`
|
||||
AccountID uint `json:"account_id"`
|
||||
SenderID *uint `json:"sender_id"`
|
||||
Topic string `json:"topic"`
|
||||
Title string `json:"title"`
|
||||
Subtitle *string `json:"subtitle"`
|
||||
Body string `json:"body"`
|
||||
Metadata datatypes.JSONMap `json:"metadata"`
|
||||
Avatar *string `json:"avatar"`
|
||||
Picture *string `json:"picture"`
|
||||
SenderID *uint `json:"sender_id"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
||||
IsRealtime bool `json:"is_realtime" gorm:"-"`
|
||||
IsForcePush bool `json:"is_force_push" gorm:"-"`
|
||||
@ -33,5 +35,7 @@ type NotificationSubscriber struct {
|
||||
Provider string `json:"provider"`
|
||||
DeviceID string `json:"device_id" gorm:"uniqueIndex"`
|
||||
DeviceToken string `json:"device_token"`
|
||||
AccountID uint `json:"account_id"`
|
||||
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user