package com.qqchen.deploy.backend.deploy.entity;

import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
import com.qqchen.deploy.backend.framework.enums.MonitorMetricEnum;
import com.qqchen.deploy.backend.framework.domain.Entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * 服务器告警规则实体
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@jakarta.persistence.Entity
@Table(name = "deploy_server_alert_rule")
@LogicDelete(true)
public class ServerAlertRule extends Entity<Long> {

    /**
     * 服务器ID（NULL表示全局规则）
     */
    @Column(name = "server_id")
    private Long serverId;

    /**
     * 规则名称
     */
    @Column(name = "rule_name", nullable = false, length = 100)
    private String ruleName;

    /**
     * 监控指标类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "alert_type", nullable = false, length = 20)
    private MonitorMetricEnum alertType;

    /**
     * 警告阈值(%)
     */
    @Column(name = "warning_threshold", nullable = false, precision = 5, scale = 2)
    private BigDecimal warningThreshold;

    /**
     * 严重阈值(%)
     */
    @Column(name = "critical_threshold", nullable = false, precision = 5, scale = 2)
    private BigDecimal criticalThreshold;

    /**
     * 持续时长(分钟)
     */
    @Column(name = "duration_minutes")
    private Integer durationMinutes = 5;

    /**
     * 是否启用
     */
    @Column(name = "enabled")
    private Boolean enabled = true;

    /**
     * 规则描述
     */
    @Column(name = "description", length = 500)
    private String description;
}
