thread-master/internal/model/knowledge_graph/domain/usecase/usecase.go

63 lines
1.5 KiB
Go

package usecase
import (
"context"
libkg "haixun-backend/internal/library/knowledge"
)
type GraphSummary struct {
ID string
BrandID string
TopicID string
Seed string
Nodes []libkg.Node
Edges []libkg.Edge
BraveSources []libkg.BraveSource
ExpandStrategy string
PainTagCount int
GeneratedAt int64
CreateAt int64
UpdateAt int64
}
type UpsertRequest struct {
TenantID string
OwnerUID string
BrandID string
TopicID string
Seed string
Nodes []libkg.Node
Edges []libkg.Edge
BraveSources []libkg.BraveSource
ExpandStrategy string
PainTagCount int
GeneratedAt int64
}
type NodeUpdate struct {
NodeID string
SelectedForScan *bool
RelevanceTags []string
RelevanceTagsSet bool
RecencyTags []string
RecencyTagsSet bool
}
type UpdateNodesRequest struct {
TenantID string
OwnerUID string
BrandID string
TopicID string
Updates []NodeUpdate
}
type UseCase interface {
Get(ctx context.Context, tenantID, ownerUID, brandID string) (*GraphSummary, error)
// brandID enables legacy fallback when graph was stored under brand_id without topic_id.
GetByTopic(ctx context.Context, tenantID, ownerUID, topicID, brandID string) (*GraphSummary, error)
Upsert(ctx context.Context, req UpsertRequest) (*GraphSummary, error)
UpdateNodes(ctx context.Context, req UpdateNodesRequest) (*GraphSummary, error)
AttachTopicID(ctx context.Context, tenantID, ownerUID, brandID, topicID string) error
}