package com.erp.task.dto;

import com.erp.task.enums.TaskStatus;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 定时任务DTO
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ScheduledTaskDTO {

    private Long id;

    @NotBlank(message = "任务名称不能为空")
    @Size(max = 100, message = "任务名称不能超过100字符")
    private String taskName;

    @Size(max = 500, message = "任务描述不能超过500字符")
    private String description;

    @NotBlank(message = "任务分组不能为空")
    @Size(max = 50, message = "任务分组不能超过50字符")
    private String taskGroup;

    @NotBlank(message = "Cron表达式不能为空")
    @Size(max = 100, message = "Cron表达式不能超过100字符")
    private String cronExpression;

    @NotBlank(message = "任务类名不能为空")
    @Size(max = 500, message = "任务类名不能超过500字符")
    private String taskClass;

    @Size(max = 100, message = "任务方法名不能超过100字符")
    private String methodName;

    private String taskParams;

    private Map<String, Object> taskParamsMap;

    @NotNull(message = "任务状态不能为空")
    private TaskStatus status;

    private Boolean concurrent = true;

    private Boolean sync = false;

    @NotBlank(message = "任务类型不能为空")
    private String taskType;

    private Long xxlJobId;

    private Integer maxRetries = 3;

    private Integer retryInterval = 60;

    private Integer timeout;

    private String alertEmails;

    private String alertPhones;

    private Boolean alertEnabled = false;

    private String misfirePolicy = "DO_NOTHING";

    private LocalDateTime nextFireTime;

    private LocalDateTime prevFireTime;

    private Long executeCount = 0L;

    @Size(max = 50, message = "负责人不能超过50字符")
    private String owner;

    @Size(max = 500, message = "备注不能超过500字符")
    private String remark;

    private String tenantId;

    private LocalDateTime createdAt;

    private LocalDateTime updatedAt;
}
