Files
yovision/Bell/server/app/bell/contact/model.go
T

69 lines
2.7 KiB
Go

package contact
import (
"encoding/json"
"time"
)
type Contact struct {
ID string `json:"id" gorm:"type:uuid;primaryKey"`
Name string `json:"name" gorm:"size:128;not null"`
Role string `json:"role" gorm:"size:128;not null"`
Enabled bool `json:"enabled" gorm:"not null;default:true;index"`
Version int `json:"version" gorm:"not null;default:1"`
CreatedBy int `json:"createdBy" gorm:"not null"`
UpdatedBy int `json:"updatedBy" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz;not null"`
UpdatedAt time.Time `json:"updatedAt" gorm:"type:timestamptz;not null"`
}
func (Contact) TableName() string { return "bell_contacts" }
type Channel struct {
ID string `json:"id" gorm:"type:uuid;primaryKey"`
ContactID string `json:"contactId" gorm:"type:uuid;not null;index"`
Kind string `json:"kind" gorm:"size:16;not null"`
AddressCiphertext []byte `json:"-" gorm:"type:bytea;not null"`
AddressFingerprint string `json:"-" gorm:"size:64;not null;index"`
AddressMasked string `json:"addressMasked" gorm:"size:64;not null"`
CreatedBy int `json:"createdBy" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz;not null"`
}
func (Channel) TableName() string { return "bell_contact_channels" }
type ChannelValidation struct {
ID string `json:"id" gorm:"type:uuid;primaryKey"`
ChannelID string `json:"channelId" gorm:"type:uuid;not null;index"`
Status string `json:"status" gorm:"size:16;not null"`
Detail string `json:"detail" gorm:"size:256;not null"`
ActorID int `json:"actorId" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz;not null;index"`
}
func (ChannelValidation) TableName() string { return "bell_contact_channel_validations" }
type AuditFact struct {
ID string `json:"id" gorm:"type:uuid;primaryKey"`
ContactID string `json:"contactId" gorm:"type:uuid;not null;index"`
Action string `json:"action" gorm:"size:32;not null"`
Snapshot json.RawMessage `json:"snapshot" gorm:"type:jsonb;not null"`
ActorID int `json:"actorId" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz;not null"`
}
func (AuditFact) TableName() string { return "bell_contact_audit_facts" }
type ChannelView struct {
ID string `json:"id"`
Kind string `json:"kind"`
AddressMasked string `json:"addressMasked"`
Status string `json:"status"`
ValidatedAt *time.Time `json:"validatedAt,omitempty"`
}
type ContactView struct {
Contact
Channels []ChannelView `json:"channels"`
}