Compare commits

...

8 Commits

2 changed files with 16 additions and 0 deletions

View File

@@ -199,3 +199,7 @@ type GCUser struct {
Username string `json:"username"` Username string `json:"username"`
AcdAutoAnswer bool `json:"acdAutoAnswer"` AcdAutoAnswer bool `json:"acdAutoAnswer"`
} }
func (GCUser) TableName() string {
return "gc_users"
}

View File

@@ -2,6 +2,8 @@ package models
import ( import (
"time" "time"
"gorm.io/gorm"
) )
type DBParticipant struct { type DBParticipant struct {
@@ -23,8 +25,18 @@ type DBParticipant struct {
WrapupRequired *bool WrapupRequired *bool
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"` 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 { func (DBParticipant) TableName() string {
return "gc_participants" 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
}