diff --git a/src/main/java/com/loafle/overflow/dao/target/dao/JPATargetDao.java b/src/main/java/com/loafle/overflow/dao/target/dao/JPATargetDao.java new file mode 100644 index 0000000..0f177b7 --- /dev/null +++ b/src/main/java/com/loafle/overflow/dao/target/dao/JPATargetDao.java @@ -0,0 +1,30 @@ +package com.loafle.overflow.dao.target.dao; + +import com.loafle.overflow.commons.dao.JPABaseDAO; +import com.loafle.overflow.dao.target.model.Target; + +import javax.persistence.Query; +import java.util.List; + +/** + * Created by root on 17. 6. 5. + */ +public class JPATargetDao extends JPABaseDAO implements TargetDao { + + public List findAll(Target target) { + + Query query = getEntityManager().createNativeQuery("SELECT tg.* FROM Target tg WHERE tg.MEMBER_ID = :memberId", Target.class); + query.setParameter("memberId", target.getMember().getId()); + + List targets = null; + try { + targets = (List)query.getResultList(); + }catch(Exception e) { + e.printStackTrace(); + }finally { + return targets; + } + + + } +} diff --git a/src/main/java/com/loafle/overflow/dao/target/dao/TargetDao.java b/src/main/java/com/loafle/overflow/dao/target/dao/TargetDao.java new file mode 100644 index 0000000..ec92e13 --- /dev/null +++ b/src/main/java/com/loafle/overflow/dao/target/dao/TargetDao.java @@ -0,0 +1,14 @@ +package com.loafle.overflow.dao.target.dao; + +import com.loafle.overflow.commons.dao.BaseDAO; +import com.loafle.overflow.dao.target.model.Target; + +import java.util.List; + +/** + * Created by root on 17. 6. 5. + */ +public interface TargetDao extends BaseDAO { + + List findAll(Target target); +} diff --git a/src/main/java/com/loafle/overflow/dao/target/model/Target.java b/src/main/java/com/loafle/overflow/dao/target/model/Target.java new file mode 100644 index 0000000..7908060 --- /dev/null +++ b/src/main/java/com/loafle/overflow/dao/target/model/Target.java @@ -0,0 +1,130 @@ +package com.loafle.overflow.dao.target.model; + +import com.loafle.overflow.dao.member.model.Member; +import com.loafle.overflow.dao.target.type.PortType; +import com.loafle.overflow.dao.target.type.TargetType; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 5. + */ +@Entity +public class Target { + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + private Long id; + + @Column(name="IP", nullable=false) + private long ip; + + @Column(name="PORT") + private int port; + + @Column(name="TARGET_TYPE") + @Enumerated(EnumType.STRING) + private TargetType targetType; + + @Column(name="VENDOR_NAME") + private String vendorName; + + @Column(name="KINDS") + private String kinds; + + @Column(name="VERSION") + private String version; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="CREATE_DATE", nullable=false , columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false) + private Date createDate; + + @Column(name="PORT_TYPE") + @Enumerated(EnumType.STRING) + private PortType portType; + + @ManyToOne + @JoinColumn(name = "MEMBER_ID", nullable=false) + private Member member; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public long getIp() { + return ip; + } + + public void setIp(long ip) { + this.ip = ip; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public TargetType getTargetType() { + return targetType; + } + + public void setTargetType(TargetType targetType) { + this.targetType = targetType; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getKinds() { + return kinds; + } + + public void setKinds(String kinds) { + this.kinds = kinds; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public Member getMember() { + return member; + } + + public void setMember(Member member) { + this.member = member; + } + + public PortType getPortType() { + return portType; + } + + public void setPortType(PortType portType) { + this.portType = portType; + } +} diff --git a/src/main/java/com/loafle/overflow/dao/target/type/PortType.java b/src/main/java/com/loafle/overflow/dao/target/type/PortType.java new file mode 100644 index 0000000..fd5d019 --- /dev/null +++ b/src/main/java/com/loafle/overflow/dao/target/type/PortType.java @@ -0,0 +1,19 @@ +package com.loafle.overflow.dao.target.type; + +/** + * Created by root on 17. 6. 7. + */ +public enum PortType { + + TCP("TCP"), + UDP("UDP"); + + + private String stringValue; + PortType(String string) {stringValue = string;} + + @Override + public String toString() { + return stringValue; + } +} diff --git a/src/main/java/com/loafle/overflow/dao/target/type/TargetType.java b/src/main/java/com/loafle/overflow/dao/target/type/TargetType.java new file mode 100644 index 0000000..d8a45cc --- /dev/null +++ b/src/main/java/com/loafle/overflow/dao/target/type/TargetType.java @@ -0,0 +1,21 @@ +package com.loafle.overflow.dao.target.type; + +/** + * Created by root on 17. 6. 5. + */ +public enum TargetType { + + MACHINE("MACHINE"), + DATABASE("DATABASE"), + WAS("WAS"), + OTHER("OTHER"); + + private String stringValue; + TargetType(String string) {stringValue = string;} + + @Override + public String toString() { + return stringValue; + } + +}