package com.qqchen.deploy.backend.deploy.dto;

import com.qqchen.deploy.backend.framework.enums.MonitorMetricEnum;
import com.qqchen.deploy.backend.framework.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * 服务器告警规则DTO
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "服务器告警规则")
public class ServerAlertRuleDTO extends BaseDTO {

    @Schema(description = "服务器ID（NULL表示全局规则）")
    private Long serverId;

    @Schema(description = "规则名称", required = true)
    @NotBlank(message = "规则名称不能为空")
    @Size(max = 100, message = "规则名称长度不能超过100个字符")
    private String ruleName;

    @Schema(description = "监控指标类型: CPU/MEMORY/DISK/NETWORK", required = true)
    @NotNull(message = "监控指标类型不能为空")
    private MonitorMetricEnum alertType;

    @Schema(description = "警告阈值(CPU/MEMORY/DISK为%，NETWORK为MB/s)", required = true, example = "80.00")
    @NotNull(message = "警告阈值不能为空")
    @DecimalMin(value = "0.00", message = "警告阈值必须大于等于0")
    @DecimalMax(value = "10000.00", message = "警告阈值不能超过10000")
    private BigDecimal warningThreshold;

    @Schema(description = "严重阈值(CPU/MEMORY/DISK为%，NETWORK为MB/s)", required = true, example = "90.00")
    @NotNull(message = "严重阈值不能为空")
    @DecimalMin(value = "0.00", message = "严重阈值必须大于等于0")
    @DecimalMax(value = "10000.00", message = "严重阈值不能超过10000")
    private BigDecimal criticalThreshold;

    @Schema(description = "持续时长(分钟)", example = "5")
    @Min(value = 1, message = "持续时长至少为1分钟")
    private Integer durationMinutes;

    @Schema(description = "是否启用")
    private Boolean enabled;

    @Schema(description = "规则描述")
    @Size(max = 500, message = "描述长度不能超过500个字符")
    private String description;
}
