From ea236aa2791f7249514a67e01a8d6ec2b0073d5e Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 24 Apr 2018 17:41:08 +0900 Subject: [PATCH] history model change --- .../module/history/dao/HistoryDAO.java | 12 +- .../central/module/history/model/History.java | 116 ------------------ ...ervice.java => CentralHistoryService.java} | 16 +-- 3 files changed, 15 insertions(+), 129 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/central/module/history/model/History.java rename src/main/java/com/loafle/overflow/central/module/history/service/{HistoryService.java => CentralHistoryService.java} (71%) diff --git a/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java index 8fc6ed3..99303b5 100644 --- a/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java @@ -1,9 +1,9 @@ package com.loafle.overflow.central.module.history.dao; -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.history.model.History; -import com.loafle.overflow.central.module.meta.model.MetaHistoryType; -import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.model.domain.Domain; +import com.loafle.overflow.model.history.History; +import com.loafle.overflow.model.probe.Probe; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -21,10 +21,10 @@ public interface HistoryDAO extends JpaRepository { Page findAllByProbe(Probe probe, Pageable pageable); @Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}") - Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable); + Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageable); Page findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest); @Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}") - Page findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest); + Page findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageRequest); } diff --git a/src/main/java/com/loafle/overflow/central/module/history/model/History.java b/src/main/java/com/loafle/overflow/central/module/history/model/History.java deleted file mode 100644 index 2a80826..0000000 --- a/src/main/java/com/loafle/overflow/central/module/history/model/History.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.loafle.overflow.central.module.history.model; - -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.member.model.Member; -import com.loafle.overflow.central.module.meta.model.MetaHistoryType; -import com.loafle.overflow.central.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 Domain domain; - - //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; - } - - @ManyToOne - @JoinColumn(name = "DOMAIN_ID", nullable = false) - public Domain getDomain() { - return domain; - } - - public void setDomain(Domain domain) { - this.domain = domain; - } - - @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/central/module/history/service/HistoryService.java b/src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java similarity index 71% rename from src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java rename to src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java index b733721..c72be13 100644 --- a/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java +++ b/src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java @@ -1,18 +1,20 @@ package com.loafle.overflow.central.module.history.service; -import com.loafle.overflow.central.commons.model.PageParams; import com.loafle.overflow.central.commons.utils.PageUtil; -import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.central.module.history.dao.HistoryDAO; -import com.loafle.overflow.central.module.history.model.History; -import com.loafle.overflow.central.module.meta.model.MetaHistoryType; -import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.core.model.PageParams; +import com.loafle.overflow.model.domain.Domain; +import com.loafle.overflow.model.history.History; +import com.loafle.overflow.model.meta.MetaHistoryType; +import com.loafle.overflow.model.probe.Probe; +import com.loafle.overflow.service.central.history.HistoryService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @Service("HistoryService") -public class HistoryService { +public class CentralHistoryService implements HistoryService { @Autowired private HistoryDAO historyDAO; @@ -26,7 +28,7 @@ public class HistoryService { return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams)); } - public Page readAllByProbe(Probe probe, PageParams pageParams) { + public Page readAllByProbe(Probe probe, com.loafle.overflow.core.model.PageParams pageParams) { return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams)); }