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

49 lines
2.3 KiB
Go

package campaign
import (
"time"
"github.com/gochat/gochat/internal/model"
)
// CampaignStatus represents the lifecycle state of a campaign.
type CampaignStatus string
const (
CampaignStatusActive CampaignStatus = "active"
CampaignStatusCompleted CampaignStatus = "completed"
)
// CampaignType represents the type of campaign.
type CampaignType string
const (
CampaignTypeOngoing CampaignType = "ongoing"
CampaignTypeOneOff CampaignType = "one_off"
)
// Campaign represents a proactive outreach campaign.
// Reference: Chatwoot Campaign model — account_id, inbox_id, sender_id, display_id,
// title, message, description, campaign_status, campaign_type, audience (jsonb),
// trigger_rules (jsonb), template_params (jsonb), scheduled_at, enabled,
// trigger_only_during_business_hours.
type Campaign struct {
model.Base
AccountID uint `gorm:"index;not null" json:"account_id"`
InboxID uint `gorm:"index;not null" json:"inbox_id"`
SenderID *uint `gorm:"index" json:"sender_id,omitempty"`
DisplayID uint `gorm:"uniqueIndex:idx_campaign_display;not null" json:"display_id"`
Title string `gorm:"size:255;not null" json:"title"`
Message string `gorm:"type:text;not null" json:"message"`
Description string `gorm:"type:text" json:"description"`
CampaignStatus CampaignStatus `gorm:"size:50;index;default:active" json:"campaign_status"`
CampaignType CampaignType `gorm:"size:50;not null" json:"campaign_type"`
Audience string `gorm:"type:jsonb;default:'{}'" json:"audience"`
TriggerRules string `gorm:"type:jsonb;default:'{}'" json:"trigger_rules"`
TemplateParams string `gorm:"type:jsonb;default:'{}'" json:"template_params"`
ScheduledAt *time.Time `gorm:"index" json:"scheduled_at,omitempty"`
Enabled bool `gorm:"default:true" json:"enabled"`
TriggerOnlyDuringBusinessHours bool `gorm:"default:false" json:"trigger_only_during_business_hours"`
}
func (Campaign) TableName() string { return "campaigns" }