package io.wdd.rpc.scheduler.beans;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder(toBuilder = true)
@ApiModel("定时脚本任务的VO实体类")
public class ScriptSchedulerVO {

    public static final String SCRIPT_SCHEDULE_MISSION_GROUP_NAME = "SCRIPT_SCHEDULER";

    /**
     *
     */
    @TableId(value = "scheduler_uuid")
    @Nullable
    private String schedulerUuid;

    /**
     *
     */
    @TableField(value = "name")
    @NotNull
    private String name;

    /**
     *
     */
    @TableField(value = "cron_express")
    @NotNull
    private String cronExpress;

    /**
     *
     */
    @TableField(value = "description")
    @Nullable
    private String description;

    /**
     * 脚本任务的内容
     */
    @TableField(value = "script_content")
    @ApiModelProperty("单行命令之间使用 空格 分隔, 每一行之间使用 \\n 分隔")
    @Nullable
    private String scriptContent;

    /**
     * 脚本任务的类型
     */
    @TableField(value = "script_type")
    @Nullable
    private String scriptType;


    @TableField(value = "script_content")
    @ApiModelProperty("脚本内容是否是持久化任务")
    @Nullable
    private boolean scriptIsDuration;

    /**
     * 执行目标机器agent_topic_name列表，使用, 分隔
     */
    @TableField(value = "target_machine")
    @Nullable
    private String targetMachine;

    /**
     * 与 execution_log表的主键对应,方便查询执行日志
     */
    @TableField(value = "last_execution_id")
    @Nullable
    private Long lastExecutionId;

    /**
     * 与 execution_log表的 result_key 对应,方便查询执行日志
     */
    @TableField(value = "last_execution_result_key")
    @Nullable
    private String lastExecutionResultKey;

    /**
     * 任务上次执行状态
     */
    @TableField(value = "last_execution_status")
    @Nullable
    private Integer lastExecutionStatus;

    /**
     * 定时脚本任务创建时间
     */
    @TableField(value = "create_time")
    @NotNull
    private LocalDateTime createTime;

    /**
     * 上次更新时间
     */
    @TableField(value = "update_time")
    @Nullable
    private LocalDateTime updateTime;

    /**
     * 任务下次计划执行时间
     */
    @TableField(value = "next_schedule_time")
    @Nullable
    private LocalDateTime nextScheduleTime;

    /**
     * 任务上次计划执行时间
     */
    @TableField(value = "last_schedule_time")
    @Nullable
    private LocalDateTime lastScheduleTime;
}
