Compare commits

..

7 Commits

Author SHA1 Message Date
db89056468 Added BeforeSave 2025-10-23 17:02:52 +11:00
567470372f askilhdfjasdgf 2025-10-23 16:59:06 +11:00
674f7dd5f5 asdnfujklsreghyiujlfhhsdrlgkif 2025-10-23 16:55:59 +11:00
f50333d223 Made user nullable in participant 2025-10-23 16:44:56 +11:00
a7f73eb96a Fixed typo 2025-10-23 16:32:18 +11:00
57b4791a4a Fixed typo 2025-10-23 16:30:35 +11:00
7737b8b4d2 Added tablename for GC users 2025-10-23 16:01:34 +11:00
2 changed files with 17 additions and 3 deletions

View File

@@ -192,10 +192,14 @@ type UsersQuery struct {
} }
type GCUser struct { type GCUser struct {
Id string `json:"id" gorm:"primaryKey;foreignKey"` Id string `json:"id" gorm:"primaryKey"`
Name string `json:"name"` Name string `json:"name"`
Email string `json:"email"` Email string `json:"email"`
State string `json:"state"` State string `json:"state"`
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,10 +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;referencesId` Calls []DBCall `gorm:"foreignKey:ParticipantId;references:Id"`
User GCUser `gorm:"foreignKey:UserId;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
}