diff --git a/src/main/java/com/loafle/overflow/module/infra/Infra.java b/src/main/java/com/loafle/overflow/module/infra/Infra.java index c9021d3..c85fce8 100644 --- a/src/main/java/com/loafle/overflow/module/infra/Infra.java +++ b/src/main/java/com/loafle/overflow/module/infra/Infra.java @@ -1,5 +1,7 @@ package com.loafle.overflow.module.infra; +import com.loafle.overflow.meta.MetaInfraType; + import javax.persistence.*; import java.sql.Timestamp; @@ -10,12 +12,12 @@ import java.sql.Timestamp; @Table(name = "TBL_INFRA", schema = "public", catalog = "postgres") public class Infra { private long id; - private int typeId; + private MetaInfraType type; private long childId; private Timestamp createDate; @Id - @Column(name = "ID", nullable = false) + @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { return id; } @@ -24,14 +26,14 @@ public class Infra { this.id = id; } - @Basic - @Column(name = "TYPE_ID", nullable = false) - public int getTypeId() { - return typeId; + @ManyToOne + @JoinColumn(name = "TYPE_ID", nullable = false) + public MetaInfraType getType() { + return type; } - public void setTypeId(int typeId) { - this.typeId = typeId; + public void setTypeId(MetaInfraType type) { + this.type = type; } @Basic @@ -45,7 +47,7 @@ public class Infra { } @Basic - @Column(name = "CREATE_DATE", nullable = false) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Timestamp getCreateDate() { return createDate; } @@ -54,27 +56,4 @@ public class Infra { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Infra tblInfra = (Infra) o; - - if (id != tblInfra.id) return false; - if (typeId != tblInfra.typeId) return false; - if (childId != tblInfra.childId) return false; - if (createDate != null ? !createDate.equals(tblInfra.createDate) : tblInfra.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + typeId; - result = 31 * result + (int) (childId ^ (childId >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/member/model/Member.java b/src/main/java/com/loafle/overflow/module/member/model/Member.java index 8e646ab..f722a70 100644 --- a/src/main/java/com/loafle/overflow/module/member/model/Member.java +++ b/src/main/java/com/loafle/overflow/module/member/model/Member.java @@ -101,7 +101,7 @@ public class Member { this.createDate = createDate; } - @ManyToMany + @ManyToOne @JoinColumn(name = "STATUS_ID", nullable = false) public MetaMemberStatus getStatus() { return status; diff --git a/src/main/java/com/loafle/overflow/module/sensor/model/Sensor.java b/src/main/java/com/loafle/overflow/module/sensor/model/Sensor.java index 8f69636..54b213b 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/model/Sensor.java +++ b/src/main/java/com/loafle/overflow/module/sensor/model/Sensor.java @@ -1,5 +1,8 @@ package com.loafle.overflow.module.sensor.model; +import com.loafle.overflow.meta.MetaCrawler; +import com.loafle.overflow.module.target.model.Target; + import javax.persistence.*; import java.sql.Timestamp; @@ -13,12 +16,12 @@ public class Sensor { private Timestamp createDate; private String desc; private String status; - private long targetId; - private short crawlerId; - private String crawelrInputItems; + private Target target; + private MetaCrawler crawler; + private String crawlerInputItems; @Id - @Column(name = "ID", nullable = false) + @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { return id; } @@ -28,7 +31,7 @@ public class Sensor { } @Basic - @Column(name = "CREATE_DATE", nullable = false) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Timestamp getCreateDate() { return createDate; } @@ -57,64 +60,34 @@ public class Sensor { this.status = status; } - @Basic - @Column(name = "TARGET_ID", nullable = false) - public long getTargetId() { - return targetId; + @ManyToOne + @JoinColumn(name = "TARGET_ID", nullable = false) + public Target getTarget() { + return target; } - public void setTargetId(long targetId) { - this.targetId = targetId; + public void setTarget(Target target) { + this.target = target; } - @Basic - @Column(name = "CRAWLER_ID", nullable = false) - public short getCrawlerId() { - return crawlerId; + @ManyToOne + @JoinColumn(name = "CRAWLER_ID", nullable = false) + public MetaCrawler getCrawler() { + return crawler; } - public void setCrawlerId(short crawlerId) { - this.crawlerId = crawlerId; + public void setCrawler(MetaCrawler crawler) { + this.crawler = crawler; } @Basic @Column(name = "CRAWELR_INPUT_ITEMS", nullable = true, length = 50) - public String getCrawelrInputItems() { - return crawelrInputItems; + public String getcrawlerInputItems() { + return crawlerInputItems; } - public void setCrawelrInputItems(String crawelrInputItems) { - this.crawelrInputItems = crawelrInputItems; + public void setcrawlerInputItems(String crawlerInputItems) { + this.crawlerInputItems = crawlerInputItems; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Sensor tblSensor = (Sensor) o; - - if (id != tblSensor.id) return false; - if (targetId != tblSensor.targetId) return false; - if (crawlerId != tblSensor.crawlerId) return false; - if (createDate != null ? !createDate.equals(tblSensor.createDate) : tblSensor.createDate != null) return false; - if (desc != null ? !desc.equals(tblSensor.desc) : tblSensor.desc != null) return false; - if (status != null ? !status.equals(tblSensor.status) : tblSensor.status != null) return false; - if (crawelrInputItems != null ? !crawelrInputItems.equals(tblSensor.crawelrInputItems) : tblSensor.crawelrInputItems != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (desc != null ? desc.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (int) (targetId ^ (targetId >>> 32)); - result = 31 * result + (int) crawlerId; - result = 31 * result + (crawelrInputItems != null ? crawelrInputItems.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/sensor/model/SensorItem.java b/src/main/java/com/loafle/overflow/module/sensor/model/SensorItem.java index 0c341dc..f77e105 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/model/SensorItem.java +++ b/src/main/java/com/loafle/overflow/module/sensor/model/SensorItem.java @@ -1,5 +1,7 @@ package com.loafle.overflow.module.sensor.model; +import com.loafle.overflow.meta.MetaSensorItem; + import javax.persistence.*; import java.sql.Timestamp; @@ -10,12 +12,12 @@ import java.sql.Timestamp; @Table(name = "TBL_SENSOR_ITEM", schema = "public", catalog = "postgres") public class SensorItem { private long id; - private long sensorId; - private long itemId; + private Sensor sensor; + private MetaSensorItem item; private Timestamp createDate; @Id - @Column(name = "ID", nullable = false) + @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { return id; } @@ -24,28 +26,28 @@ public class SensorItem { this.id = id; } - @Basic - @Column(name = "SENSOR_ID", nullable = false) - public long getSensorId() { - return sensorId; + @ManyToOne + @JoinColumn(name = "SENSOR_ID", nullable = false) + public Sensor getSensor() { + return this.sensor; } - public void setSensorId(long sensorId) { - this.sensorId = sensorId; + public void setSensor(Sensor sensor) { + this.sensor = sensor; + } + + @ManyToOne + @JoinColumn(name = "ITEM_ID", nullable = false) + public MetaSensorItem getItem() { + return item; + } + + public void setItem(MetaSensorItem item) { + this.item = item; } @Basic - @Column(name = "ITEM_ID", nullable = false) - public long getItemId() { - return itemId; - } - - public void setItemId(long itemId) { - this.itemId = itemId; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Timestamp getCreateDate() { return createDate; } @@ -54,27 +56,4 @@ public class SensorItem { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SensorItem that = (SensorItem) o; - - if (id != that.id) return false; - if (sensorId != that.sensorId) return false; - if (itemId != that.itemId) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (sensorId ^ (sensorId >>> 32)); - result = 31 * result + (int) (itemId ^ (itemId >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } }