gorm_models/models/participant.go

43 lines
1.3 KiB
Go
Raw Normal View History

2025-06-16 17:49:27 +10:00
package models
import (
"time"
2025-10-23 17:02:52 +11:00
"gorm.io/gorm"
2025-06-16 17:49:27 +10:00
)
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
2025-10-19 19:16:41 +11:00
UserId *string
2025-06-16 17:49:27 +10:00
Wrapup *string `gorm:"type:json"`
WrapupExpected *bool
WrapupRequired *bool
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
2025-10-23 16:32:18 +11:00
Calls []DBCall `gorm:"foreignKey:ParticipantId;references:Id"`
2025-10-23 16:55:59 +11:00
User *GCUser `gorm:"foreignKey:UserId;references:Id"`
2025-06-16 17:49:27 +10:00
}
func (DBParticipant) TableName() string {
return "gc_participants"
}
2025-10-23 17:02:52 +11:00
func (p *DBParticipant) BeforeSave(tx *gorm.DB) error {
// Convert empty string to nil
if p.UserId != nil && *p.UserId == "" {
p.UserId = nil
}
return nil
}