Files
gochat/internal/model/contactable.go.txt
T
2026-06-04 15:44:48 +08:00

20 lines
774 B
Plaintext

package model
import (
"time"
)
// Contactable represents a polymorphic association for contact-related records.
// Reference: P2B M4 Contactable pattern
type Contactable struct {
ID uint `gorm:"primaryKey" json:"id"`
ContactID uint `gorm:"not null;index" json:"contact_id"`
ContactableType string `gorm:"size:100;not null;index" json:"contactable_type"` // Contact/User/AgentBot
ContactableID uint `gorm:"not null;index" json:"contactable_id"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
Contact Contact `gorm:"foreignKey:ContactID" json:"contact,omitempty"`
}
func (Contactable) TableName() string { return "contactables" }