history model change
This commit is contained in:
parent
0d444fc58e
commit
ea236aa279
|
@ -1,9 +1,9 @@
|
||||||
package com.loafle.overflow.central.module.history.dao;
|
package com.loafle.overflow.central.module.history.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.central.module.history.model.History;
|
import com.loafle.overflow.model.history.History;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
@ -21,10 +21,10 @@ public interface HistoryDAO extends JpaRepository<History, Long> {
|
||||||
Page<History> findAllByProbe(Probe probe, Pageable pageable);
|
Page<History> findAllByProbe(Probe probe, Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
|
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
|
||||||
Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable);
|
Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageable);
|
||||||
|
|
||||||
Page<History> findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest);
|
Page<History> 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}")
|
@Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}")
|
||||||
Page<History> findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest);
|
Page<History> findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,20 @@
|
||||||
package com.loafle.overflow.central.module.history.service;
|
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.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.dao.HistoryDAO;
|
||||||
import com.loafle.overflow.central.module.history.model.History;
|
import com.loafle.overflow.core.model.PageParams;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service("HistoryService")
|
@Service("HistoryService")
|
||||||
public class HistoryService {
|
public class CentralHistoryService implements HistoryService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HistoryDAO historyDAO;
|
private HistoryDAO historyDAO;
|
||||||
|
@ -26,7 +28,7 @@ public class HistoryService {
|
||||||
return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<History> readAllByProbe(Probe probe, PageParams pageParams) {
|
public Page<History> readAllByProbe(Probe probe, com.loafle.overflow.core.model.PageParams pageParams) {
|
||||||
return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user