thread-master/apps/backend/internal/module/scout/domain/domain.go

152 lines
7.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package domain
import (
"errors"
"time"
)
var (
ErrNotFound = errors.New("scout not found")
ErrForbidden = errors.New("scout forbidden")
ErrValidation = errors.New("scout validation")
ErrNoCrawlerSession = errors.New("crawler session required when dev_mode enabled")
ErrTopicRemoved = errors.New("ScoutTopic CRUD removed")
ErrHasProducts = errors.New("brand has products; remove products first")
)
func NowNano() int64 { return time.Now().UTC().UnixNano() }
const (
PathAPI = "api"
PathCrawler = "crawler"
OutreachNew = "new"
OutreachDrafted = "drafted"
OutreachPublished = "published"
OutreachSkipped = "skipped"
OutreachQueued = "queued"
ModeProduct = "product"
ModeTheme = "theme"
ModeActivity = "activity"
ModeDemand = "demand"
ModeProvider = "provider"
ClassificationSeekingHelp = "seeking_help"
ClassificationSeekingRecommendation = "seeking_recommendation"
ClassificationProviderOffer = "provider_offer"
ClassificationDiscussion = "discussion"
ClassificationAsking = "asking"
ClassificationAnnouncement = "announcement"
ClassificationNoise = "noise"
ClassificationProviderDirect = "provider_direct"
ClassificationProviderRecommended = "provider_recommended"
)
type Brand struct {
ID string `bson:"_id" json:"id"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
DisplayName string `bson:"display_name" json:"display_name"`
Brief string `bson:"brief" json:"brief"`
TargetAudience string `bson:"target_audience,omitempty" json:"target_audience,omitempty"`
Goals string `bson:"goals,omitempty" json:"goals,omitempty"`
// Learning — growth-loop 資產複利
LearningSummary string `bson:"learning_summary,omitempty" json:"learning_summary,omitempty"`
LearningVersion int `bson:"learning_version,omitempty" json:"learning_version,omitempty"`
LearnedFromPostsCount int `bson:"learned_from_posts_count,omitempty" json:"learned_from_posts_count,omitempty"`
LastLearnedAt int64 `bson:"last_learned_at,omitempty" json:"last_learned_at,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
type Product struct {
ID string `bson:"_id" json:"id"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
BrandID string `bson:"brand_id" json:"brand_id"`
Label string `bson:"label" json:"label"`
ProductContext string `bson:"product_context" json:"product_context"`
MatchTags []string `bson:"match_tags" json:"match_tags"`
PainPoints []string `bson:"pain_points" json:"pain_points"`
ProviderCapabilityTerms []string `bson:"provider_capability_terms" json:"provider_capability_terms"`
ProviderExcludeTerms []string `bson:"provider_exclude_terms" json:"provider_exclude_terms"`
PlacementURL string `bson:"placement_url,omitempty" json:"placement_url,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
type ActiveBrand struct {
OwnerUID int64 `bson:"_id" json:"owner_uid"`
BrandID string `bson:"brand_id" json:"brand_id"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
}
type RunBrief struct {
Intent string `json:"intent"`
Mode string `json:"mode"`
BrandID string `json:"brand_id,omitempty"`
ProductID string `json:"product_id,omitempty"`
ProductLabel string `json:"product_label,omitempty"`
Pains []string `json:"pains"`
Tags []string `json:"tags"`
Periphery []string `json:"periphery"`
ScanTerms []string `json:"scan_terms"`
PlacementNote string `json:"placement_note,omitempty"`
ResponseStance string `json:"response_stance,omitempty"`
ThemeKey string `json:"theme_key,omitempty"`
ThemeLabel string `json:"theme_label,omitempty"`
ProductContext string `json:"product_context,omitempty"`
}
type Post struct {
ID string `bson:"_id" json:"id"`
ExternalID string `bson:"external_id,omitempty" json:"external_id,omitempty"`
Permalink string `bson:"permalink,omitempty" json:"permalink,omitempty"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
BrandID string `bson:"brand_id,omitempty" json:"brand_id,omitempty"`
Author string `bson:"author" json:"author"`
Text string `bson:"text" json:"text"`
SearchTag string `bson:"search_tag" json:"search_tag"`
Opportunity string `bson:"opportunity" json:"opportunity"`
OutreachStatus string `bson:"outreach_status" json:"outreach_status"`
DraftText string `bson:"draft_text,omitempty" json:"draft_text,omitempty"`
OutboxID string `bson:"outbox_id,omitempty" json:"outbox_id,omitempty"`
Score int `bson:"score" json:"score"`
Classification string `bson:"classification,omitempty" json:"classification,omitempty"`
MatchedProductID string `bson:"matched_product_id,omitempty" json:"matched_product_id,omitempty"`
MatchedProductLabel string `bson:"matched_product_label,omitempty" json:"matched_product_label,omitempty"`
MatchReason string `bson:"match_reason,omitempty" json:"match_reason,omitempty"`
ScoutMode string `bson:"scout_mode,omitempty" json:"scout_mode,omitempty"`
IntentSnippet string `bson:"intent_snippet,omitempty" json:"intent_snippet,omitempty"`
ThemeKey string `bson:"theme_key,omitempty" json:"theme_key,omitempty"`
ThemeLabel string `bson:"theme_label,omitempty" json:"theme_label,omitempty"`
ScanPath string `bson:"scan_path,omitempty" json:"scan_path,omitempty"` // api|crawler
// PostedAt = 原文發文時間unix ns未知時為 0列表以 PostedAt 優先、再 CreatedAt
PostedAt int64 `bson:"posted_at,omitempty" json:"posted_at,omitempty"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
}
type Homework struct {
ThemeKey string `bson:"_id" json:"theme_key"`
OwnerUID int64 `bson:"owner_uid" json:"owner_uid"`
ThemeLabel string `bson:"theme_label" json:"theme_label"`
Purpose string `bson:"purpose" json:"purpose"`
Brief RunBrief `bson:"brief" json:"brief"`
CreatedAt int64 `bson:"created_at" json:"created_at"`
}
type CrawlerSession struct {
OwnerUID int64 `bson:"_id" json:"owner_uid"`
StorageStateEnc string `bson:"storage_state_enc" json:"storage_state_enc"`
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
ExpiresAt int64 `bson:"expires_at" json:"expires_at"`
}
type ImportDraft struct {
Label string `json:"label"`
ProductContext string `json:"product_context"`
PainPoints []string `json:"pain_points"`
MatchTags []string `json:"match_tags"`
PlacementURL string `json:"placement_url"`
SourceNote string `json:"source_note"`
}