package com.dora.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotBlank;

/**
 * AI任务提交请求DTO
 * 
 * <p>支持以下功能：
 * <ul>
 *   <li>文生图/视频：只需提供prompt</li>
 *   <li>图生视频：提供prompt + imageUrl或imageBase64</li>
 * </ul>
 * 
 * @author 1818AI
 * @since 2025-10-20
 */
@Data
public class TaskSubmitRequest {

    @NotBlank(message = "模型名称不能为空")
    @Schema(description = "要使用的AI模型名称", example = "sora_image", required = true)
    private String modelName;

    @NotBlank(message = "提示词不能为空")
    @Schema(description = "用户输入的提示词/场景描述", example = "一只可爱的猫咪在花园里玩耍", required = true)
    private String prompt;

    @Schema(description = "参考图片URL（用于图生视频）", 
            example = "https://example.com/image.jpg",
            required = false)
    private String imageUrl;

    @Schema(description = "参考图片Base64编码（用于图生视频，与imageUrl二选一）", 
            example = "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
            required = false)
    private String imageBase64;

    @Schema(description = "图片宽高比（可选）", example = "2:3")
    private String aspectRatio;

    @Schema(description = "来源任务编号（用于续作）", example = "T20251023123456")
    private String sourceTaskNo;

    /**
     * 检查是否为图生视频任务
     */
    public boolean isImageToVideo() {
        return (imageUrl != null && !imageUrl.trim().isEmpty()) || 
               (imageBase64 != null && !imageBase64.trim().isEmpty());
    }

    /**
     * 获取有效的图片参数（优先使用URL）
     */
    public String getEffectiveImageParam() {
        if (imageUrl != null && !imageUrl.trim().isEmpty()) {
            return imageUrl;
        }
        return imageBase64;
    }
}
