[monitor]数据库实体对象类迁移到common包
This commit is contained in:
@@ -2,11 +2,11 @@ package com.usthe.manager.component.alerter;
|
||||
|
||||
import com.usthe.alert.AlerterDataQueue;
|
||||
import com.usthe.alert.AlerterWorkerPool;
|
||||
import com.usthe.alert.pojo.entity.Alert;
|
||||
import com.usthe.common.entity.alerter.Alert;
|
||||
import com.usthe.alert.service.AlertService;
|
||||
import com.usthe.common.util.CommonConstants;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.NoticeReceiver;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.common.entity.manager.NoticeReceiver;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import com.usthe.manager.service.NoticeConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.dto.Hierarchy;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.entity.NoticeReceiver;
|
||||
import com.usthe.manager.pojo.entity.NoticeRule;
|
||||
import com.usthe.common.entity.manager.NoticeReceiver;
|
||||
import com.usthe.common.entity.manager.NoticeRule;
|
||||
import com.usthe.manager.service.NoticeConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.NoticeReceiver;
|
||||
import com.usthe.common.entity.manager.NoticeReceiver;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.NoticeRule;
|
||||
import com.usthe.common.entity.manager.NoticeRule;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
import com.usthe.common.entity.manager.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* ParamDefine数据库操作
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.usthe.manager.pojo.dto;
|
||||
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.common.entity.manager.Param;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.usthe.manager.pojo.dto;
|
||||
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import com.usthe.common.util.GsonUtil;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* json 互转map对象字段为数据String字段
|
||||
* @author tom
|
||||
* @date 2021/12/4 07:54
|
||||
*/
|
||||
public class JsonOptionListAttributeConverter implements AttributeConverter<List<ParamDefine.Option>, String> {
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(List<ParamDefine.Option> attribute) {
|
||||
return GsonUtil.toJson(attribute);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ParamDefine.Option> convertToEntityAttribute(String dbData) {
|
||||
return GsonUtil.fromJson(dbData, List.class);
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import com.usthe.manager.support.valid.HostValid;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 监控实体
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 9:53
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "monitor")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "监控实体")
|
||||
public class Monitor {
|
||||
|
||||
@Id
|
||||
@ApiModelProperty(value = "监控ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控对应下发的任务ID
|
||||
*/
|
||||
@ApiModelProperty(value = "任务ID", example = "43243543543", accessMode = READ_ONLY, position = 1)
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* 监控的名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控名称", example = "Api-TanCloud.cn", accessMode = READ_WRITE, position = 2)
|
||||
@Length(max = 100)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 监控的类型:linux,mysql,jvm...
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 100)
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* 监控的对端host:ipv4,ipv6,域名
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的对端host", example = "192.167.25.11", accessMode = READ_WRITE, position = 4)
|
||||
@Length(max = 100)
|
||||
@HostValid
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 监控的采集间隔时间,单位秒
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的采集间隔时间,单位秒", example = "600", accessMode = READ_WRITE, position = 5)
|
||||
@Min(10)
|
||||
private Integer intervals;
|
||||
|
||||
/**
|
||||
* 监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起
|
||||
*/
|
||||
@ApiModelProperty(value = "监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起", accessMode = READ_WRITE, position = 6)
|
||||
@Min(0)
|
||||
@Max(4)
|
||||
private byte status;
|
||||
|
||||
/**
|
||||
* 监控备注描述
|
||||
*/
|
||||
@ApiModelProperty(value = "监控备注描述", example = "对SAAS网站TanCloud的可用性监控", accessMode = READ_WRITE, position = 7)
|
||||
@Length(max = 255)
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 9)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 10)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 11)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 消息通知接收人实体
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "notice_receiver")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "消息通知接收人实体")
|
||||
public class NoticeReceiver {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "接收人实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "接收人名称", example = "tom", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号", accessMode = READ_WRITE, position = 2)
|
||||
@Min(0)
|
||||
@Max(3)
|
||||
@NotNull
|
||||
private Byte type;
|
||||
|
||||
@ApiModelProperty(value = "手机号, 通知方式为手机短信时有效", example = "18923435643", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 100)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱账号, 通知方式为邮箱时有效", example = "tom@qq.com", accessMode = READ_WRITE, position = 4)
|
||||
@Length(max = 100)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "URL地址, 通知方式为webhook有效", example = "https://www.tancloud.cn", accessMode = READ_WRITE, position = 5)
|
||||
@Length(max = 100)
|
||||
private String hookUrl;
|
||||
|
||||
@ApiModelProperty(value = "wechat用户openId, 通知方式为微信公众号有效", example = "343432", accessMode = READ_WRITE, position = 6)
|
||||
@Length(max = 100)
|
||||
private String wechatId;
|
||||
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String modifier;
|
||||
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 通知策略
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "notice_rule")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "通知策略实体")
|
||||
public class NoticeRule {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "通知策略实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "策略名称", example = "dispatch-1", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "接收人ID", example = "4324324", accessMode = READ_WRITE, position = 2)
|
||||
@NotNull
|
||||
private Long receiverId;
|
||||
|
||||
@ApiModelProperty(value = "接收人标识", example = "tom", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String receiverName;
|
||||
|
||||
@ApiModelProperty(value = "是否启用此策略", example = "true", accessMode = READ_WRITE, position = 4)
|
||||
private boolean enable = true;
|
||||
|
||||
@ApiModelProperty(value = "是否转发所有", example = "false", accessMode = READ_WRITE, position = 5)
|
||||
private boolean filterAll = true;
|
||||
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String modifier;
|
||||
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 监控参数值
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "param")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数实体")
|
||||
public class Param {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控ID
|
||||
*/
|
||||
@ApiModelProperty(value = "监控ID", example = "875846754543", accessMode = READ_WRITE, position = 1)
|
||||
private Long monitorId;
|
||||
|
||||
/**
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数标识符字段", example = "port", accessMode = READ_WRITE, position = 2)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* 参数值
|
||||
*/
|
||||
@ApiModelProperty(value = "参数值", example = "8080", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 255)
|
||||
@NotNull
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 参数类型 0:数字 1:字符串 2:加密串
|
||||
*/
|
||||
@ApiModelProperty(value = "参数类型 0:数字 1:字符串 2:加密串", accessMode = READ_WRITE, position = 4)
|
||||
@Min(0)
|
||||
@Max(2)
|
||||
private byte type;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 5)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 6)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* todo 字段默认值
|
||||
* 监控参数定义
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 21:49
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "param_define")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数结构定义实体")
|
||||
public class ParamDefine {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数结构ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控应用类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 1)
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* 参数字段对外显示名称
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段显示名称", example = "端口", accessMode = READ_WRITE, position = 2)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段标识符", example = "port", accessMode = READ_WRITE, position = 3)
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* 字段类型,样式(大部分映射input标签type属性)
|
||||
*/
|
||||
@ApiModelProperty(value = "字段类型,样式(大部分映射input标签type属性)", example = "number", accessMode = READ_WRITE, position = 4)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 是否是必输项 true-必填 false-可选
|
||||
*/
|
||||
@ApiModelProperty(value = "是否是必输项 true-必填 false-可选", example = "true", accessMode = READ_WRITE, position = 5)
|
||||
private boolean required = false;
|
||||
|
||||
/**
|
||||
* 参数默认值
|
||||
*/
|
||||
@ApiModelProperty(value = "参数默认值", example = "12", accessMode = READ_WRITE, position = 6)
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* 参数输入框提示信息
|
||||
*/
|
||||
@ApiModelProperty(value = "参数输入框提示信息", example = "请输入密码", accessMode = READ_WRITE, position = 7)
|
||||
private String placeholder;
|
||||
|
||||
/**
|
||||
* 当type为number时,用range表示范围 eg: 0-233
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为number时,用range区间表示范围", example = "[0,233]", accessMode = READ_WRITE, position = 6)
|
||||
@Column(name = "param_range")
|
||||
private String range;
|
||||
|
||||
/**
|
||||
* 当type为text时,用limit表示字符串限制大小.最大255
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为text时,用limit表示字符串限制大小.最大255", example = "30", accessMode = READ_WRITE, position = 7)
|
||||
@Column(name = "param_limit")
|
||||
private Short limit;
|
||||
|
||||
/**
|
||||
* 当type为radio单选框,checkbox复选框时,options表示可选项值列表
|
||||
* eg: {
|
||||
* "key1":"value1",
|
||||
* "key2":"value2"
|
||||
* }
|
||||
* key-值显示标签
|
||||
* value-真正值
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为radio单选框,checkbox复选框时,option表示可选项值列表", example = "{key1,value1}", accessMode = READ_WRITE, position = 8)
|
||||
@Column(name = "param_options")
|
||||
@Convert(converter = JsonOptionListAttributeConverter.class)
|
||||
private List<Option> options;
|
||||
|
||||
/**
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 9)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 10)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 11)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 12)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static final class Option {
|
||||
/**
|
||||
* 值显示标签
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* 可选值
|
||||
*/
|
||||
private String value;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.usthe.manager.service;
|
||||
|
||||
import com.usthe.common.entity.job.Job;
|
||||
import com.usthe.manager.pojo.dto.Hierarchy;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.usthe.manager.service;
|
||||
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.common.entity.manager.Param;
|
||||
import com.usthe.manager.support.exception.MonitorDetectException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.usthe.manager.service;
|
||||
|
||||
import com.usthe.alert.pojo.entity.Alert;
|
||||
import com.usthe.manager.pojo.entity.NoticeReceiver;
|
||||
import com.usthe.manager.pojo.entity.NoticeRule;
|
||||
import com.usthe.common.entity.alerter.Alert;
|
||||
import com.usthe.common.entity.manager.NoticeReceiver;
|
||||
import com.usthe.common.entity.manager.NoticeRule;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.usthe.common.entity.job.Metrics;
|
||||
import com.usthe.manager.dao.ParamDefineDao;
|
||||
import com.usthe.manager.pojo.dto.Hierarchy;
|
||||
import com.usthe.manager.pojo.dto.ParamDefineDto;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -14,9 +14,9 @@ import com.usthe.manager.dao.MonitorDao;
|
||||
import com.usthe.manager.dao.ParamDao;
|
||||
import com.usthe.manager.pojo.dto.AppCount;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.common.entity.manager.Param;
|
||||
import com.usthe.common.entity.manager.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import com.usthe.manager.support.exception.MonitorDatabaseException;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.usthe.manager.service.impl;
|
||||
|
||||
import com.usthe.alert.pojo.entity.Alert;
|
||||
import com.usthe.common.entity.alerter.Alert;
|
||||
import com.usthe.manager.dao.NoticeReceiverDao;
|
||||
import com.usthe.manager.dao.NoticeRuleDao;
|
||||
import com.usthe.manager.pojo.entity.NoticeReceiver;
|
||||
import com.usthe.manager.pojo.entity.NoticeRule;
|
||||
import com.usthe.common.entity.manager.NoticeReceiver;
|
||||
import com.usthe.common.entity.manager.NoticeRule;
|
||||
import com.usthe.manager.service.NoticeConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.usthe.manager.support;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Spring的ApplicationContext的持有者,可以用静态方法的方式获取spring容器中的bean
|
||||
* @author tomsun28
|
||||
* @date 21:07 2018/4/18
|
||||
*/
|
||||
@Component
|
||||
public class SpringContextHolder implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
set(applicationContext);
|
||||
}
|
||||
|
||||
private static void set(ApplicationContext applicationContext) {
|
||||
SpringContextHolder.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
assertApplicationContext();
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String beanName) {
|
||||
assertApplicationContext();
|
||||
return (T) applicationContext.getBean(beanName);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> tClass) {
|
||||
assertApplicationContext();
|
||||
return (T) applicationContext.getBean(tClass);
|
||||
}
|
||||
|
||||
private static void assertApplicationContext() {
|
||||
if (null == SpringContextHolder.applicationContext) {
|
||||
throw new RuntimeException("applicationContext为空,请检查是否注入springContextHolder");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.usthe.manager.support.valid;
|
||||
|
||||
import com.usthe.common.util.IpDomainUtil;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* host注解数据自定义校验器
|
||||
* @author tomsun28
|
||||
* @date 2021/11/17 19:44
|
||||
*/
|
||||
public class HostParamValidator implements ConstraintValidator<HostValid, String> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||
// 判断value是否满足ipv4 ipv5 域名 格式
|
||||
return IpDomainUtil.validateIpDomain(value);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.usthe.manager.support.valid;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* host注解数据自定义校验器注解
|
||||
* @author tomsun28
|
||||
* @date 2021/11/17 19:42
|
||||
*/
|
||||
@Target({ FIELD, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = HostParamValidator.class)
|
||||
public @interface HostValid {
|
||||
|
||||
String message() default "Host value is invalid,must ipv4, ipv6 or domain";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
Reference in New Issue
Block a user