gorm_models/models/participant.go

43 lines
1.3 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
type DBParticipant struct {
Address *string
Attributes *string `gorm:"type:json"`
ConnectedTime *time.Time `gorm:"index"`
ConversationId string `gorm:"foreignKey;index"`
EndTime *time.Time `gorm:"index"`
ExternalContactId *string
ExternalContactInitialDivisionId *string
Id string `gorm:"primaryKey;index"`
MediaRoles *string `gorm:"type:json"`
Name *string `gorm:"index"`
Purpose *string `gorm:"index"`
QueueId *string
UserId *string
Wrapup *string `gorm:"type:json"`
WrapupExpected *bool
WrapupRequired *bool
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
Calls []DBCall `gorm:"foreignKey:ParticipantId;references:Id"`
User *GCUser `gorm:"foreignKey:UserId;references:Id"`
}
func (DBParticipant) TableName() string {
return "gc_participants"
}
func (p *DBParticipant) BeforeSave(tx *gorm.DB) error {
// Convert empty string to nil
if p.UserId != nil && *p.UserId == "" {
p.UserId = nil
}
return nil
}