package dto

import (
	"time"

	"quyun/v2/pkg/consts"
)

// ContentCreateForm defines payload for tenant-admin to create a new content draft.
type ContentCreateForm struct {
	// Title is the content title.
	Title string `json:"title,omitempty"`
	// Description is the content description.
	Description string `json:"description,omitempty"`
	// Visibility controls who can view the content detail (main assets still require free/purchase).
	Visibility consts.ContentVisibility `json:"visibility,omitempty"`
	// PreviewSeconds controls preview duration (defaults to 60 when omitted).
	PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
}

// ContentUpdateForm updates mutable fields of a content.
type ContentUpdateForm struct {
	// Title updates the title when provided.
	Title *string `json:"title,omitempty"`
	// Description updates the description when provided.
	Description *string `json:"description,omitempty"`
	// Visibility updates the visibility when provided.
	Visibility *consts.ContentVisibility `json:"visibility,omitempty"`
	// Status updates the content status when provided (e.g. publish/unpublish).
	Status *consts.ContentStatus `json:"status,omitempty"`
	// PreviewSeconds updates preview duration when provided (must be > 0).
	PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
}

// ContentPriceUpsertForm upserts pricing and discount settings for a content.
type ContentPriceUpsertForm struct {
	// PriceAmount is the base price in cents (CNY 分).
	PriceAmount int64 `json:"price_amount,omitempty"`
	// Currency is fixed to CNY for now.
	Currency consts.Currency `json:"currency,omitempty"`
	// DiscountType defines the discount algorithm (none/percent/amount).
	DiscountType consts.DiscountType `json:"discount_type,omitempty"`
	// DiscountValue is interpreted based on DiscountType.
	DiscountValue int64 `json:"discount_value,omitempty"`
	// DiscountStartAt enables discount from this time (optional).
	DiscountStartAt *time.Time `json:"discount_start_at,omitempty"`
	// DiscountEndAt disables discount after this time (optional).
	DiscountEndAt *time.Time `json:"discount_end_at,omitempty"`
}

// ContentAssetAttachForm attaches a media asset to a content with a role and sort order.
type ContentAssetAttachForm struct {
	// AssetID is the media asset id to attach.
	AssetID int64 `json:"asset_id,omitempty"`
	// Role indicates how this asset is used (main/cover/preview).
	Role consts.ContentAssetRole `json:"role,omitempty"`
	// Sort controls ordering under the same role.
	Sort int32 `json:"sort,omitempty"`
}
