package usecase

import (
	"context"

	"haixun-backend/internal/model/brand/domain/entity"
)

type ProductSummary struct {
	ID             string
	Label          string
	ProductContext string
	MatchTags      []string
	CreateAt       int64
	UpdateAt       int64
}

type BrandSummary struct {
	ID             string
	DisplayName    string
	TopicName      string
	SeedQuery      string
	Brief          string
	ProductBrief   string
	ProductContext string
	ProductID      string
	Products       []ProductSummary
	TargetAudience string
	Goals          string
	ResearchMap    entity.ResearchMap
	CreateAt       int64
	UpdateAt       int64
}

type CreateRequest struct {
	TenantID       string
	OwnerUID       string
	DisplayName    string
	SeedQuery      string
	Brief          string
	ProductContext string
	ProductBrief   string
	TargetAudience string
	Goals          string
	ResearchMap    *entity.ResearchMap
}

type UpdateRequest struct {
	TenantID string
	OwnerUID string
	BrandID  string
	Patch    BrandPatch
}

type BrandPatch struct {
	DisplayName       *string
	TopicName         *string
	SeedQuery         *string
	Brief             *string
	ProductBrief      *string
	ProductContext    *string
	ProductID         *string
	TargetAudience    *string
	Goals             *string
	AudienceSummary   *string
	ContentGoal       *string
	Questions         []string
	QuestionsSet      bool
	Pillars           []string
	PillarsSet        bool
	Exclusions        []string
	ExclusionsSet     bool
	ResearchMap       *entity.ResearchMap
	PatrolKeywords    []string
	PatrolKeywordsSet bool
}

type ListResult struct {
	List []BrandSummary
}

type ListProductsResult struct {
	List []ProductSummary
}

type CreateProductRequest struct {
	TenantID       string
	OwnerUID       string
	BrandID        string
	Label          string
	ProductContext string
	MatchTags      []string
}

type UpdateProductRequest struct {
	TenantID       string
	OwnerUID       string
	BrandID        string
	ProductID      string
	Label          *string
	ProductContext *string
	MatchTags      []string
	MatchTagsSet   bool
}

type UseCase interface {
	List(ctx context.Context, tenantID, ownerUID string) (*ListResult, error)
	Create(ctx context.Context, req CreateRequest) (*BrandSummary, error)
	Get(ctx context.Context, tenantID, ownerUID, brandID string) (*BrandSummary, error)
	Update(ctx context.Context, req UpdateRequest) (*BrandSummary, error)
	Delete(ctx context.Context, tenantID, ownerUID, brandID string) error
	ListProducts(ctx context.Context, tenantID, ownerUID, brandID string) (*ListProductsResult, error)
	CreateProduct(ctx context.Context, req CreateProductRequest) (*ProductSummary, error)
	UpdateProduct(ctx context.Context, req UpdateProductRequest) (*ProductSummary, error)
	DeleteProduct(ctx context.Context, tenantID, ownerUID, brandID, productID string) error
}
