From db5fa69e03fbc5137bfc39b353bc44954f700f47 Mon Sep 17 00:00:00 2001 From: zhou-hao Date: Wed, 15 Apr 2020 12:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=A1=E9=AA=8C=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/device/entity/DeviceInstanceEntity.java | 2 ++ .../community/device/entity/DeviceProductEntity.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceInstanceEntity.java b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceInstanceEntity.java index d91829b9..3ae9d4cc 100644 --- a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceInstanceEntity.java +++ b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceInstanceEntity.java @@ -20,6 +20,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.Index; import javax.persistence.Table; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; import java.sql.JDBCType; import java.util.Collections; import java.util.Map; @@ -33,6 +34,7 @@ public class DeviceInstanceEntity extends GenericEntity implements Recor @Override @GeneratedValue(generator = Generators.SNOW_FLAKE) + @Pattern(regexp = "^[0-9a-zA-Z_\\-]+$", message = "ID只能由英文下划线和中划线组成",groups = CreateGroup.class) public String getId() { return super.getId(); } diff --git a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceProductEntity.java b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceProductEntity.java index bfc709f7..21eb6a74 100644 --- a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceProductEntity.java +++ b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceProductEntity.java @@ -15,6 +15,7 @@ import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.Table; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; import java.sql.JDBCType; import java.util.Map; @@ -25,6 +26,10 @@ public class DeviceProductEntity extends GenericEntity implements Record @Override @GeneratedValue(generator = Generators.SNOW_FLAKE) + @Pattern( + regexp = "^[0-9a-zA-Z_\\-]+$", + message = "ID只能由英文下划线和中划线组成", + groups = CreateGroup.class) public String getId() { return super.getId(); } @@ -61,7 +66,6 @@ public class DeviceProductEntity extends GenericEntity implements Record @Comment("协议元数据") @Column(name = "metadata") @ColumnType(jdbcType = JDBCType.CLOB) - @NotBlank(message = "元数据不能为空",groups = CreateGroup.class) private String metadata; @Comment("传输协议: MQTT,COAP,UDP")