From 1e467e64c5314c903561b45cc355fa15a4342952 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 23 Aug 2017 12:56:34 +0900 Subject: [PATCH] History module --- .../overflow/module/history/History.java | 54 --------- .../module/history/dao/HistoryDAO.java | 10 ++ .../module/history/model/History.java | 104 ++++++++++++++++++ .../history/service/HistoryService.java | 9 ++ .../module/meta/dao/MetaHistoryTypeDAO.java | 13 +++ .../module/meta/model/MetaHistoryType.java | 45 ++++++++ .../meta/service/MetaHistoryTypeService.java | 22 ++++ 7 files changed, 203 insertions(+), 54 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/module/history/History.java create mode 100644 src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java create mode 100644 src/main/java/com/loafle/overflow/module/history/model/History.java create mode 100644 src/main/java/com/loafle/overflow/module/history/service/HistoryService.java create mode 100644 src/main/java/com/loafle/overflow/module/meta/dao/MetaHistoryTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java create mode 100644 src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java diff --git a/src/main/java/com/loafle/overflow/module/history/History.java b/src/main/java/com/loafle/overflow/module/history/History.java deleted file mode 100644 index f449457..0000000 --- a/src/main/java/com/loafle/overflow/module/history/History.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.loafle.overflow.module.history; - -import javax.persistence.*; -import java.util.Date; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "HISTORY", schema = "public") -public class History { - private long id; - private Date createDate; - - @Id - @GeneratedValue(strategy= GenerationType.IDENTITY) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "CREATE_DATE", nullable = false) - public Date getCreateDate() { - return createDate; - } - - public void setCreateDate(Date createDate) { - this.createDate = createDate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - History that = (History) o; - - if (id != that.id) 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 + (createDate != null ? createDate.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java b/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java new file mode 100644 index 0000000..788bf2a --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java @@ -0,0 +1,10 @@ +package com.loafle.overflow.module.history.dao; + +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 8. 23. + */ +@Repository +public class HistoryDAO { +} diff --git a/src/main/java/com/loafle/overflow/module/history/model/History.java b/src/main/java/com/loafle/overflow/module/history/model/History.java new file mode 100644 index 0000000..44bfbe3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/history/model/History.java @@ -0,0 +1,104 @@ +package com.loafle.overflow.module.history.model; + +import com.loafle.overflow.module.member.model.Member; +import com.loafle.overflow.module.meta.model.MetaHistoryType; +import com.loafle.overflow.module.probe.model.Probe; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "HISTORY", schema = "public") +public class History { + private long id; + private Date createDate; + private MetaHistoryType type; + private String message; + private Probe probe; + private Member member; + + //private MetaResultType resultType; // i'm not sure this is necessary + + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + @ManyToOne + @JoinColumn(name = "TYPE_ID", nullable = false) + public MetaHistoryType getType() { + return type; + } + + public void setType(MetaHistoryType type) { + this.type = type; + } + + @Column(name = "MESSAGE", nullable = false, length = 255) + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @ManyToOne + @JoinColumn(name = "PROBE_ID", nullable = false) + public Probe getProbe() { + return probe; + } + + public void setProbe(Probe probe) { + this.probe = probe; + } + + @ManyToOne + @JoinColumn(name = "Member_ID", nullable = false) + public Member getMember() { + return member; + } + + public void setMember(Member member) { + this.member = member; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + History that = (History) o; + + if (id != that.id) 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 + (createDate != null ? createDate.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java b/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java new file mode 100644 index 0000000..e8cb783 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java @@ -0,0 +1,9 @@ +package com.loafle.overflow.module.history.service; + +import org.springframework.stereotype.Service; + +@Service("HistoryService") +public class HistoryService { + + +} diff --git a/src/main/java/com/loafle/overflow/module/meta/dao/MetaHistoryTypeDAO.java b/src/main/java/com/loafle/overflow/module/meta/dao/MetaHistoryTypeDAO.java new file mode 100644 index 0000000..146708e --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/meta/dao/MetaHistoryTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.module.meta.dao; + +import com.loafle.overflow.module.meta.model.MetaInfraType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaHistoryTypeDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java b/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java new file mode 100644 index 0000000..c19ca4e --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java @@ -0,0 +1,45 @@ +package com.loafle.overflow.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_INFRA_TYPE", schema = "public") +public class MetaHistoryType { + private int id; + private String name; + private Date createDate; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java b/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java new file mode 100644 index 0000000..0ba0e43 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.module.meta.service; + +import com.loafle.overflow.module.meta.dao.MetaHistoryTypeDAO; +import com.loafle.overflow.module.meta.model.MetaInfraType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaInfraTypeService") +public class MetaHistoryTypeService { + + @Autowired + private MetaHistoryTypeDAO hisotyTypeDAO; + + public List readAll() { + return this.hisotyTypeDAO.findAll(); + } +}