model
This commit is contained in:
parent
c7ee2bb74b
commit
95d3cacd41
|
@ -1,146 +0,0 @@
|
|||
package com.loafle.overflow.models;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "TBL_MEMBER", schema = "public", catalog = "postgres")
|
||||
public class TblMember {
|
||||
private long id;
|
||||
private String email;
|
||||
private String pw;
|
||||
private String pwSalt;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String companyName;
|
||||
private Timestamp createDate;
|
||||
private short statusId;
|
||||
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "EMAIL", nullable = false, length = 50)
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PW", nullable = true, length = 32)
|
||||
public String getPw() {
|
||||
return pw;
|
||||
}
|
||||
|
||||
public void setPw(String pw) {
|
||||
this.pw = pw;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PW_SALT", nullable = true, length = 32)
|
||||
public String getPwSalt() {
|
||||
return pwSalt;
|
||||
}
|
||||
|
||||
public void setPwSalt(String pwSalt) {
|
||||
this.pwSalt = pwSalt;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "NAME", nullable = true, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PHONE", nullable = true, length = 50)
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "COMPANY_NAME", nullable = true, length = 50)
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public void setCompanyName(String companyName) {
|
||||
this.companyName = companyName;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "CREATE_DATE", nullable = true)
|
||||
public Timestamp getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Timestamp createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "STATUS_ID", nullable = false)
|
||||
public short getStatusId() {
|
||||
return statusId;
|
||||
}
|
||||
|
||||
public void setStatusId(short statusId) {
|
||||
this.statusId = statusId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TblMember tblMember = (TblMember) o;
|
||||
|
||||
if (id != tblMember.id) return false;
|
||||
if (statusId != tblMember.statusId) return false;
|
||||
if (email != null ? !email.equals(tblMember.email) : tblMember.email != null) return false;
|
||||
if (pw != null ? !pw.equals(tblMember.pw) : tblMember.pw != null) return false;
|
||||
if (pwSalt != null ? !pwSalt.equals(tblMember.pwSalt) : tblMember.pwSalt != null) return false;
|
||||
if (name != null ? !name.equals(tblMember.name) : tblMember.name != null) return false;
|
||||
if (phone != null ? !phone.equals(tblMember.phone) : tblMember.phone != null) return false;
|
||||
if (companyName != null ? !companyName.equals(tblMember.companyName) : tblMember.companyName != null)
|
||||
return false;
|
||||
if (createDate != null ? !createDate.equals(tblMember.createDate) : tblMember.createDate != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (id ^ (id >>> 32));
|
||||
result = 31 * result + (email != null ? email.hashCode() : 0);
|
||||
result = 31 * result + (pw != null ? pw.hashCode() : 0);
|
||||
result = 31 * result + (pwSalt != null ? pwSalt.hashCode() : 0);
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (phone != null ? phone.hashCode() : 0);
|
||||
result = 31 * result + (companyName != null ? companyName.hashCode() : 0);
|
||||
result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
|
||||
result = 31 * result + (int) statusId;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package com.loafle.overflow.module.apikey.model;
|
||||
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.loafle.overflow.module.email.model;
|
||||
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.loafle.overflow.module.member.dao;
|
||||
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
|
@ -1,58 +1,38 @@
|
|||
package com.loafle.overflow.module.member.model;
|
||||
|
||||
import com.loafle.overflow.meta.MetaMemberStatus;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 5. 23.
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="MEMBER")
|
||||
public class Member implements Serializable {
|
||||
@Table(name = "TBL_MEMBER", schema = "public", catalog = "postgres")
|
||||
public class Member {
|
||||
private long id;
|
||||
private String email;
|
||||
private String pw;
|
||||
private String pwSalt;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String companyName;
|
||||
private Timestamp createDate;
|
||||
private MetaMemberStatus status;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name="EMAIL", unique=true, nullable=false)
|
||||
private String email;
|
||||
|
||||
@Column(name="PW_SALT", nullable=false)
|
||||
private String pwSalt;
|
||||
|
||||
@Column(name="DIGEST", nullable=false)
|
||||
private String digest;
|
||||
|
||||
@Column(name="NAME", nullable=false)
|
||||
private String name;
|
||||
|
||||
@Column(name="COMPANY", nullable=false)
|
||||
private String company;
|
||||
|
||||
@Column(name="PHONE")
|
||||
private String phone;
|
||||
|
||||
@Column(name="AUTHORIZED_DATE")
|
||||
private Long authorizedDate;
|
||||
|
||||
|
||||
public Member() {
|
||||
|
||||
}
|
||||
|
||||
public Member(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "EMAIL", nullable = false, length = 50)
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
@ -61,6 +41,18 @@ public class Member implements Serializable {
|
|||
this.email = email;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PW", nullable = true, length = 32)
|
||||
public String getPw() {
|
||||
return pw;
|
||||
}
|
||||
|
||||
public void setPw(String pw) {
|
||||
this.pw = pw;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PW_SALT", nullable = true, length = 32)
|
||||
public String getPwSalt() {
|
||||
return pwSalt;
|
||||
}
|
||||
|
@ -69,14 +61,8 @@ public class Member implements Serializable {
|
|||
this.pwSalt = pwSalt;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "NAME", nullable = true, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -85,14 +71,8 @@ public class Member implements Serializable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PHONE", nullable = true, length = 50)
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
@ -101,11 +81,35 @@ public class Member implements Serializable {
|
|||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Long getAuthorizedDate() {
|
||||
return authorizedDate;
|
||||
@Basic
|
||||
@Column(name = "COMPANY_NAME", nullable = true, length = 50)
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public void setAuthorizedDate(Long authorizedDate) {
|
||||
this.authorizedDate = authorizedDate;
|
||||
public void setCompanyName(String companyName) {
|
||||
this.companyName = companyName;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Timestamp getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Timestamp createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToMany
|
||||
@JoinColumn(name = "STATUS_ID", nullable = false)
|
||||
public MetaMemberStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(MetaMemberStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.loafle.overflow.module.target.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||
|
||||
import javax.persistence.Query;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 5.
|
||||
*/
|
||||
public class JPATargetDao extends JPABaseDAO<Target> implements TargetDao {
|
||||
|
||||
public List<Target> 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<Target> targets = null;
|
||||
try {
|
||||
targets = (List<Target>)query.getResultList();
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
return targets;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.module.target.dao;
|
||||
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 5.
|
||||
*/
|
||||
public interface TargetDAO extends JpaRepository<Target, Long> {
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.loafle.overflow.module.target.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 5.
|
||||
*/
|
||||
public interface TargetDao extends BaseDAO<Target> {
|
||||
|
||||
List<Target> findAll(Target target);
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.loafle.overflow.proxy.db;
|
|||
import com.loafle.overflow.db.api.DBGrpc;
|
||||
import com.loafle.overflow.db.api.DBInput;
|
||||
import com.loafle.overflow.db.api.DBOutput;
|
||||
import com.loafle.overflow.module.agent.dao.AgentDAO;
|
||||
import com.loafle.overflow.module.probe.dao.AgentDAO;
|
||||
import com.loafle.overflow.module.apikey.dao.ApiKeyDao;
|
||||
import com.loafle.overflow.module.crawler.dao.CrawlerDAO;
|
||||
import com.loafle.overflow.module.crawler.dao.CrawlerInputItemDAO;
|
||||
|
@ -13,6 +13,7 @@ import com.loafle.overflow.module.member.dao.MemberDAO;
|
|||
import com.loafle.overflow.module.noauthagent.dao.NoAuthAgentDao;
|
||||
import com.loafle.overflow.module.sensor.dao.SensorDao;
|
||||
import com.loafle.overflow.module.sensor.dao.SensorItemDao;
|
||||
import com.loafle.overflow.module.target.dao.TargetDAO;
|
||||
import io.grpc.ServerBuilder;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -53,8 +54,8 @@ public class DBProxy {
|
|||
@Autowired
|
||||
private EmailAuthDAO emailAuthDAO;
|
||||
|
||||
// @Autowired
|
||||
// private TargetDao targetDao;
|
||||
@Autowired
|
||||
private TargetDAO targetDAO;
|
||||
|
||||
@Autowired
|
||||
private CrawlerDAO crawlerDAO;
|
||||
|
@ -81,11 +82,11 @@ public class DBProxy {
|
|||
daoMap = new ConcurrentHashMap();
|
||||
|
||||
daoMap.put("member", memberDAO);
|
||||
daoMap.put("agent", agentDAO);
|
||||
daoMap.put("probe", agentDAO);
|
||||
daoMap.put("noauthAgent", noAuthAgentDAO);
|
||||
daoMap.put("apiKey", apiKeyDao);
|
||||
daoMap.put("emailAuth", emailAuthDAO);
|
||||
// daoMap.put("target", targetDao);
|
||||
// daoMap.put("target", targetDAO);
|
||||
daoMap.put("crawler", crawlerDAO);
|
||||
daoMap.put("crawlerInputItem", crawlerInputItemDAO);
|
||||
daoMap.put("crawlerInputItemMapping", crawlerInputItemMappingDAO);
|
||||
|
|
|
@ -4,7 +4,6 @@ package com.loafle;
|
|||
import com.loafle.overflow.db.api.DBGrpc;
|
||||
import com.loafle.overflow.db.api.DBInput;
|
||||
import com.loafle.overflow.db.api.DBOutput;
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//package com.loafle.overflow.agent.dao;
|
||||
//
|
||||
//import com.loafle.overflow.module.agent.dao.JPAAgentDAO;
|
||||
//import com.loafle.overflow.module.agent.model.Agent;
|
||||
//import com.loafle.overflow.module.probe.dao.JPAAgentDAO;
|
||||
//import com.loafle.overflow.module.probe.model.Agent;
|
||||
//import com.loafle.overflow.module.member.model.Member;
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Ignore;
|
||||
|
@ -25,10 +25,10 @@
|
|||
// public void createAgent() {
|
||||
// Member m = new Member();
|
||||
// m.setId(Long.valueOf(1));
|
||||
// Agent agent = new Agent();
|
||||
// agent.setDescription("test agent");
|
||||
// agent.setMember(m);
|
||||
// Agent savedAgent = jpaAgentDAO.create(agent);
|
||||
// Agent probe = new Agent();
|
||||
// probe.setDescription("test probe");
|
||||
// probe.setMember(m);
|
||||
// Agent savedAgent = jpaAgentDAO.create(probe);
|
||||
//
|
||||
// System.out.println(savedAgent.getDescription());
|
||||
// }
|
||||
|
|
|
@ -2,15 +2,12 @@ package com.loafle.overflow.module.member.dao;
|
|||
|
||||
import com.loafle.overflow.AppConfig;
|
||||
import com.loafle.overflow.JdbcConfiguration;
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.loafle.overflow.target.dao;
|
||||
|
||||
import com.loafle.overflow.module.infra.Infra;
|
||||
import com.loafle.overflow.module.target.dao.TargetDAO;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
public class JPATargetDaoTest {
|
||||
|
||||
@Autowired
|
||||
private TargetDAO repo;
|
||||
|
||||
|
||||
@Test
|
||||
public void create() {
|
||||
Target t = new Target();
|
||||
t.setCreateDate(new Timestamp(new Date().getTime()));
|
||||
|
||||
Infra i = new Infra();
|
||||
i.setId(1);
|
||||
t.setInfra(i);
|
||||
|
||||
Probe p = new Probe();
|
||||
p.setId(1);
|
||||
|
||||
Target ret = repo.save(t);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user