|
|
@@ -9,25 +9,30 @@
|
|
|
*/
|
|
|
package cc.iotkit.data.model;
|
|
|
|
|
|
-import cc.iotkit.common.tenant.dao.AbstractBaseEntity;
|
|
|
+import cc.iotkit.common.tenant.dao.TenantAware;
|
|
|
+import cc.iotkit.common.tenant.listener.TenantListener;
|
|
|
import cc.iotkit.model.product.Product;
|
|
|
import io.github.linpeilie.annotations.AutoMapper;
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
import lombok.Data;
|
|
|
+import org.hibernate.annotations.Filter;
|
|
|
+import org.hibernate.annotations.FilterDef;
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
+import org.hibernate.annotations.ParamDef;
|
|
|
|
|
|
-import javax.persistence.Entity;
|
|
|
-import javax.persistence.GeneratedValue;
|
|
|
-import javax.persistence.Id;
|
|
|
-import javax.persistence.Table;
|
|
|
+import javax.persistence.*;
|
|
|
+import javax.validation.constraints.Size;
|
|
|
|
|
|
@Data
|
|
|
@Entity
|
|
|
@ApiModel(value = "产品")
|
|
|
@Table(name = "product")
|
|
|
@AutoMapper(target = Product.class)
|
|
|
-public class TbProduct extends AbstractBaseEntity {
|
|
|
+@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")})
|
|
|
+@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
|
|
+@EntityListeners(TenantListener.class)
|
|
|
+public class TbProduct implements TenantAware {
|
|
|
|
|
|
@Id
|
|
|
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
|
|
@@ -35,6 +40,10 @@ public class TbProduct extends AbstractBaseEntity {
|
|
|
@ApiModelProperty(value = "产品id")
|
|
|
private Long id;
|
|
|
|
|
|
+ @Size(max = 30)
|
|
|
+ @Column(name = "tenant_id")
|
|
|
+ private String tenantId;
|
|
|
+
|
|
|
@ApiModelProperty(value = "产品key")
|
|
|
private String productKey;
|
|
|
|