agent
This commit is contained in:
parent
3a2453f0c8
commit
42aee25f0c
|
@ -2,9 +2,13 @@ package com.loafle.overflow.agent.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.agent.model.Agent;
|
import com.loafle.overflow.agent.model.Agent;
|
||||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||||
|
import com.loafle.overflow.member.model.Member;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 5. 29.
|
* Created by insanity on 17. 5. 29.
|
||||||
*/
|
*/
|
||||||
public interface AgentDAO extends BaseDAO<Agent> {
|
public interface AgentDAO extends BaseDAO<Agent> {
|
||||||
|
public List<Agent> findAgentListByMemberId(Member member);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,31 @@ package com.loafle.overflow.agent.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.agent.model.Agent;
|
import com.loafle.overflow.agent.model.Agent;
|
||||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||||
|
import com.loafle.overflow.member.model.Member;
|
||||||
|
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 5. 29.
|
* Created by insanity on 17. 5. 29.
|
||||||
*/
|
*/
|
||||||
public class JPAAgentDAO extends JPABaseDAO<Agent> implements AgentDAO {
|
public class JPAAgentDAO extends JPABaseDAO<Agent> implements AgentDAO {
|
||||||
|
|
||||||
|
public List<Agent> findAgentListByMemberId(Member member) {
|
||||||
|
Query query = getEntityManager()
|
||||||
|
.createNativeQuery("SELECT agt.* FROM AGENT agt WHERE agt.MEMBER_ID = :member", Agent.class);
|
||||||
|
query.setParameter("member", member.getId());
|
||||||
|
|
||||||
|
List<Agent> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
list = query.getResultList();
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.loafle.overflow.agent.model;
|
package com.loafle.overflow.agent.model;
|
||||||
|
|
||||||
|
import com.loafle.overflow.member.model.Member;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ -13,12 +15,22 @@ public class Agent implements Serializable {
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "MEMBER_ID", nullable=false)
|
||||||
|
private Member member;
|
||||||
|
|
||||||
@Column(name="AUTHORIZED_DATE")
|
@Column(name="AUTHORIZED_DATE")
|
||||||
private Long authorizedDate;
|
private Long authorizedDate;
|
||||||
|
|
||||||
@Column(name="DESCRIPTION")
|
@Column(name="DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@Column(name="LAST_POLLING_DATE")
|
||||||
|
private Long lastPollingDate;
|
||||||
|
|
||||||
|
@Column(name="STATUS")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -28,6 +40,14 @@ public class Agent implements Serializable {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Member getMember() {
|
||||||
|
return member;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMember(Member member) {
|
||||||
|
this.member = member;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getAuthorizedDate() {
|
public Long getAuthorizedDate() {
|
||||||
return authorizedDate;
|
return authorizedDate;
|
||||||
}
|
}
|
||||||
|
@ -43,4 +63,20 @@ public class Agent implements Serializable {
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getLastPollingDate() {
|
||||||
|
return lastPollingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastPollingDate(Long lastPollingDate) {
|
||||||
|
this.lastPollingDate = lastPollingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package com.loafle.overflow.agent.dao;
|
package com.loafle.overflow.agent.dao;
|
||||||
|
|
||||||
|
import com.loafle.overflow.agent.model.Agent;
|
||||||
|
import com.loafle.overflow.member.model.Member;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by root on 17. 6. 4.
|
* Created by root on 17. 6. 4.
|
||||||
*/
|
*/
|
||||||
|
@Ignore
|
||||||
public class JPAAgentDAOTest {
|
public class JPAAgentDAOTest {
|
||||||
|
|
||||||
private JPAAgentDAO jpaAgentDAO = null;
|
private JPAAgentDAO jpaAgentDAO = null;
|
||||||
|
@ -20,9 +22,14 @@ public class JPAAgentDAOTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAgent() {
|
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);
|
||||||
|
|
||||||
|
System.out.println(savedAgent.getDescription());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user