Files
rogee aeddedf2a3 Reorganize repo: backend/, deploy/, docs/ layout + AGENTS.md
Restructure the monorepo into clear top-level directories:
- backend/: Go module root (cmd, internal, pkg, configs, migrations,
  docs/swagger, scripts, tests, go.mod, Makefile, .air.toml)
- deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd
- docs/: project documentation + reports/ (moved from repo root)
- AGENTS.md: new AI coding-agent guide at repo root

Update all references to the new layout:
- Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root)
- docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile,
  env_file ../../.env, volume mounts ../../backend:/app
- deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile
- CI: working-directory: backend for go commands, file deploy/docker/Dockerfile,
  coverage path backend/coverage.out, health_check backend/scripts/
- backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../
- README: architecture tree, quickstart, config paths updated

Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh,
gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to
preserve history. Build, vet, SQLite tests, and docker compose config verified.
2026-07-07 14:44:12 +08:00

54 lines
2.4 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"
CampaignStatusProcessing CampaignStatus = "processing"
)
// 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"`
Inbox model.Inbox `gorm:"foreignKey:InboxID" json:"-"`
Sender *model.User `gorm:"foreignKey:SenderID" json:"-"`
}
func (Campaign) TableName() string { return "campaigns" }