package com.backendsys.modules.crt.entity;

import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
import com.backendsys.entity.validator.RangeArray;
import com.backendsys.entity.validator.RangeStringArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.annotations.JsonAdapter;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@TableName("crt_drama_project_storyboard")
public class CrtDramaProjectStoryboard {

    public static interface Detail{}
    public static interface StoryboardDetail{}
    public static interface Create{}
    public static interface Update{}
    public static interface Clear{}
    public static interface Delete{}
    public static interface DeleteBySort{}
    public static interface GenerateImage{}
    public static interface GenerateImageList{}

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("id")
    @NotNull(message = "分镜ID不能为空", groups = { Update.class, GenerateImage.class, GenerateImageList.class, DeleteBySort.class })
    private Long drama_project_storyboard_id;

    private Long user_id;

    @NotNull(message = "项目ID不能为空", groups = { Create.class, StoryboardDetail.class, Clear.class, Delete.class  })
    private Long drama_project_id;
    @NotNull(message = "集数不能为空", groups = { Create.class, StoryboardDetail.class, Clear.class, Delete.class  })
    @Max(value = 999, message = "集数不超过 {value}")
    private Integer episode_num;

    @NotNull(message = "序号不能为空", groups = { Create.class })
    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
    private Integer sort;

    @Size(max = 1000, message = "分镜设计长度不超过 {max} 个字符", groups = { Update.class })
    private String story_prompt;
    @Size(max = 1000, message = "景别长度不超过 {max} 个字符", groups = { Update.class })
    private String story_framing;
    @Size(max = 1000, message = "场景长度不超过 {max} 个字符", groups = { Update.class })
    private String story_scene;
    @Size(max = 1000, message = "天气/时间长度不超过 {max} 个字符", groups = { Update.class })
    private String story_weather_time;

    // 人物LoRA ID (创建时，跟随项目的人物LoRAID)(多个人物ID以逗号分隔)
    @Size(max = 255, message = "人物LoRA ID长度不超过 {max} 个字符", groups = { Update.class })
    private String lora_figure_ids;

    // 每次生成图片数量 (默认值：1，整数范围：1~4)
    @RangeArray(message="生成图片数量取值有误，范围应是(1, 2, 3, 4)", value = { "1", "2", "3", "4" }, groups = { Update.class })
    private Integer param_batch_size;

    // 提示词引导系数 (默认值：3.5，小数点后一位，范围：1~30)
    @Range(min = 1, max = 30, message = "提示词引导系数必须在 {min} 到 {max} 之间", groups = { Update.class })
    private Float param_prompt_flux_guidance;

    // 采样方法 (枚举: SamplerEnums)(Euler: euler, DPM++2M: dpmpp_2m)
    @RangeStringArray(message="采样方法取值有误，范围应是(Euler, DPM++2M)", value = { "Euler", "DPM++2M" }, groups = { Update.class })
    private String param_sampler;

    // 步数 (默认值：20，整数范围：1~30)
    @Range(min = 1, max = 30, message = "步数必须在 {min} 到 {max} 之间", groups = { Update.class })
    private Integer param_step;

    // 随机种子 (默认值：1，范围：(1:随机, 2:自定义))
    @RangeArray(message="随机种子取值有误，范围应是(1, 2)", value = { "1", "2" }, groups = { Update.class })
    private Integer param_seed_type;

    // 随机种子自定义值 (长度: 0~64位整数)
    @Size(max = 64, message = "随机种子自定义值长度不超过 {max} 个字符", groups = { Update.class })
    private String param_seed;

    // 文生图提示词 (生图时必填)
    @Size(max = 2000, message = "文生图提示词 长度不超过 {max} 个字符", groups = { Update.class })
    private String text_to_image_prompt;

    // 生视频模式 (1:首尾帧模式, 2:多图参考模式)
    @RangeArray(message="随机种子取值有误，范围应是(1, 2)", value = { "1", "2" }, groups = { Update.class })
    private Integer param_video_reference_type;

    // 参考图 (1~4张)(多图以逗号分隔)
    private String param_video_reference_images;

    // 图生视频提示词 (生视频时必填)
    private String image_to_video_prompt;

    // 生图状态 (-1:未生图, 1:生成中, 2:已生图)
    private Integer generate_image_status;

    @TableField(exist = false)
    private List<CrtGenerateImage> generate_images;

    // 生视频状态 (-1:未生视频, 1:生成中, 2:已生视频)
    private Integer generate_video_status;

//    private String create_time;
//    private String update_time;

    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime create_time;
    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime update_time;

}
