All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feingto.cloud.domain.monitor.BaseMonitorSolution Maven / Gradle / Ivy

There is a newer version: 2.3.5.RELEASE
Show newest version
package com.feingto.cloud.domain.monitor;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.feingto.cloud.domain.BaseEntity;
import com.feingto.cloud.domain.converters.ConditionPersistenceConverters;
import com.feingto.cloud.domain.system.Dict;
import com.feingto.cloud.dto.monitor.Condition;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.util.StringUtils;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 监控方案
 *
 * @author longfei
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@MappedSuperclass
public class BaseMonitorSolution extends BaseEntity {
    private static final long serialVersionUID = 7016262984648483053L;

    @NotBlank(message = "名称不能为空")
    @Column(nullable = false)
    protected String name;

    /**
     * 分类, 数据字典 rule_category
     */
    @NotNull(message = "分类不能为空")
    @Column(nullable = false)
    protected String category;

    /**
     * 规则使用的对象属性
     */
    @JsonIgnoreProperties(value = {"items", "children"}, allowSetters = true)
    @ManyToOne
    @JoinColumn
    @NotFound(action = NotFoundAction.IGNORE)
    protected Dict control;

    /**
     * 规则表达式
     */
    @Convert(converter = ConditionPersistenceConverters.class)
    @Column(name = "rule_expression", columnDefinition = "text")
    protected Condition condition;

    /**
     * 预警级别, 数据字典 rule_level
     */
    @Column(name = "rule_level")
    protected String level;

    /**
     * 邮箱地址(逗号连接字符串)
     */
    @Column
    protected String email;

    /**
     * 短信号码(逗号连接字符串)
     */
    @Column
    protected String sms;

    /**
     * 开启定时任务
     */
    @Column(nullable = false)
    @ColumnDefault("false")
    protected boolean quartz = false;

    /**
     * 开始扫描时间(小时hh)
     */
    @Column(length = 2)
    protected String startTime;

    /**
     * 停止扫描时间(小时hh)
     */
    @Column(length = 2)
    protected String endTime;

    /**
     * 定时任务扫描时间(单位:分钟)
     */
    @Column
    protected Integer scan;

    /**
     * 描述
     */
    @Column
    protected String remark;

    @Column(nullable = false)
    @ColumnDefault("false")
    protected boolean enabled = false;

    /**
     * 获取警告HTML
     */
    public static String getLevelHtml(String level, String label) {
        if (StringUtils.isEmpty(level)) return "";

        switch (level) {
            case "info":
                return "" + label + ":";
            case "warning":
                return "" + label + ":";
            case "error":
                return "" + label + ":";
            default:
                return "" + label + ":";
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy