|
|
@@ -1,8 +1,27 @@
|
|
|
package org.jetlinks.community.rule.engine.entity;
|
|
|
|
|
|
+import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import lombok.Data;
|
|
|
+import lombok.Getter;
|
|
|
+import lombok.Setter;
|
|
|
+import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
|
|
|
+import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
|
|
|
+import org.hswebframework.ezorm.rdb.mapping.annotation.EnumCodec;
|
|
|
+import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec;
|
|
|
+import org.hswebframework.web.api.crud.entity.GenericEntity;
|
|
|
+import org.hswebframework.web.api.crud.entity.RecordCreationEntity;
|
|
|
+import org.hswebframework.web.api.crud.entity.RecordModifierEntity;
|
|
|
+import org.hswebframework.web.validator.CreateGroup;
|
|
|
import org.jetlinks.community.rule.engine.device.DeviceAlarmRule;
|
|
|
+import org.jetlinks.community.rule.engine.enums.AlarmState;
|
|
|
+import org.jetlinks.community.rule.engine.enums.RuleSceneState;
|
|
|
import org.jetlinks.community.rule.engine.model.Action;
|
|
|
+
|
|
|
+import javax.persistence.Column;
|
|
|
+import javax.persistence.GeneratedValue;
|
|
|
+import javax.persistence.Table;
|
|
|
+import javax.validation.constraints.Pattern;
|
|
|
+import java.sql.JDBCType;
|
|
|
import java.util.*;
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -11,15 +30,55 @@ import java.util.*;
|
|
|
* @Description TODO
|
|
|
* @createTime 2021年08月31日 14:59:00
|
|
|
*/
|
|
|
-@Data
|
|
|
-public class RuleSceneEntity {
|
|
|
- private String id;
|
|
|
+@Getter
|
|
|
+@Setter
|
|
|
+@Table(name = "rule_scene")
|
|
|
+public class RuleSceneEntity extends GenericEntity<String> implements RecordCreationEntity {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @GeneratedValue(generator = "snow_flake")
|
|
|
+ @Pattern(regexp = "^[0-9a-zA-Z_\\-]+$", message = "ID只能由数字,字母,下划线和中划线组成", groups = CreateGroup.class)
|
|
|
+ @Schema(description = "ID")
|
|
|
+ public String getId() {
|
|
|
+ return super.getId();
|
|
|
+ }
|
|
|
|
|
|
+ @Column
|
|
|
+ @ColumnType(javaType = String.class)
|
|
|
+ @DefaultValue("false")
|
|
|
+ @Schema(description = "名称")
|
|
|
private String name;
|
|
|
|
|
|
+ @Column
|
|
|
+ @ColumnType(javaType = Boolean.class)
|
|
|
+ @DefaultValue("false")
|
|
|
+ @Schema(description = "是否并行")
|
|
|
private Boolean parallel;
|
|
|
|
|
|
+ @Column
|
|
|
+ @EnumCodec
|
|
|
+ @ColumnType(javaType = String.class)
|
|
|
+ @DefaultValue("stopped")
|
|
|
+ @Schema(description = "状态")
|
|
|
+ private RuleSceneState state;
|
|
|
+
|
|
|
+ @Column(nullable = false)
|
|
|
+ @JsonCodec
|
|
|
+ @ColumnType(jdbcType = JDBCType.CLOB, javaType = List.class)
|
|
|
+ @Schema(description = "执行行动")
|
|
|
private List<Action> actions;
|
|
|
|
|
|
+ @Column(nullable = false)
|
|
|
+ @JsonCodec
|
|
|
+ @ColumnType(jdbcType = JDBCType.CLOB, javaType = List.class)
|
|
|
+ @Schema(description = "触发器")
|
|
|
private List<DeviceAlarmRule.Trigger> triggers;
|
|
|
+
|
|
|
+ @Column(name = "create_time")
|
|
|
+ @Schema(description = "创建时间")
|
|
|
+ private Long createTime;
|
|
|
+
|
|
|
+ @Column(name = "creator_id")
|
|
|
+ @Schema(description = "创建者ID")
|
|
|
+ private String creatorId;
|
|
|
}
|