package com.njcn.gather.systemops.database.pojo.param;

import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 数据库备份参数。
 */
public class DatabaseBackupParam {

    @Data
    @ApiModel("创建备份任务参数")
    public static class CreateParam {
        @ApiModelProperty("连接 ID")
        @NotBlank(message = "连接 ID 不能为空")
        private String connectionId;
        @ApiModelProperty("备份策略：DATA_PUMP、JDBC_EXPORT，默认 DATA_PUMP")
        private String backupStrategy;
        @ApiModelProperty("Schema")
        private String schemaName;
        @ApiModelProperty("表名列表")
        private List<String> targetNames;
        @ApiModelProperty("备份模式：FULL_TABLE、TIME_RANGE、SIZE_SPLIT")
        private String backupMode;
        @ApiModelProperty("时间字段")
        private String timeColumn;
        @ApiModelProperty("开始时间")
        private LocalDateTime startTime;
        @ApiModelProperty("结束时间")
        private LocalDateTime endTime;
        @ApiModelProperty("最大文件大小 MB")
        private Integer maxFileSizeMb;
        @ApiModelProperty("Oracle Directory 名称")
        private String directoryName;
        @ApiModelProperty("临时密码，不保存密码时传入")
        private String temporaryPassword;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    @ApiModel("备份任务查询参数")
    public static class TaskQueryParam extends BaseParam {
        @ApiModelProperty("连接 ID")
        private String connectionId;
        @ApiModelProperty("任务状态")
        private String taskStatus;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    @ApiModel("备份文件查询参数")
    public static class FileQueryParam extends BaseParam {
        @ApiModelProperty("连接 ID")
        private String connectionId;
        @ApiModelProperty("任务 ID")
        private String taskId;
        @ApiModelProperty("备份策略")
        private String backupStrategy;
    }

    @Data
    @ApiModel("停止备份任务参数")
    public static class StopParam {
        @ApiModelProperty("备份任务 ID")
        @NotBlank(message = "备份任务 ID 不能为空")
        private String taskId;
    }

    @Data
    @ApiModel("重新开始备份任务参数")
    public static class RestartParam {
        @ApiModelProperty("备份任务 ID")
        @NotBlank(message = "备份任务 ID 不能为空")
        private String taskId;
        @ApiModelProperty("临时密码，原连接未保存密码时传入")
        private String temporaryPassword;
    }
}
