package model

import (
	"encoding/json"
	"time"

	"github.com/google/uuid"
)

type ScriptAnalysis struct {
	ID              uuid.UUID                 `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
	UserID          uuid.UUID                 `gorm:"type:uuid;index" json:"user_id"`
	Name            string                    `json:"name"`
	SourceContent   string                    `json:"source_content"`
	ResultContent   string                    `json:"result_content"`
	AnalysisResult  json.RawMessage           `gorm:"type:jsonb;not null;default:'{}'" json:"analysis_result"`
	AnalysisStatus  string                    `json:"analysis_status"`
	AnalysisMessage string                    `json:"analysis_message"`
	Characters      []ScriptAnalysisCharacter `gorm:"foreignKey:ScriptAnalysisID" json:"characters,omitempty"`
	CreatedAt       time.Time                 `json:"created_at"`
	UpdatedAt       time.Time                 `json:"updated_at"`
	DeletedAt       *time.Time                `json:"-"`
}

type ScriptAnalysisCharacter struct {
	ID               uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
	ScriptAnalysisID uuid.UUID `gorm:"type:uuid;index" json:"script_analysis_id"`
	Name             string    `json:"name"`
	Faction          string    `json:"faction"`
	Biography        string    `json:"biography"`
	Motivation       string    `json:"motivation"`
	Relationship     string    `json:"relationship"`
	SortOrder        int       `json:"sort_order"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}
