diff --git a/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java b/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java index 2c71d80..c605597 100644 --- a/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java +++ b/src/main/java/com/loafle/overflow/module/meta/model/MetaHistoryType.java @@ -33,7 +33,7 @@ public class MetaHistoryType { } @Temporal(TemporalType.TIMESTAMP) - @Column(name = "CREATE_DATE", nullable = false) + @Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Date getCreateDate() { return createDate; } diff --git a/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java b/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java index 6544f56..bf96e9a 100644 --- a/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java +++ b/src/main/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeService.java @@ -10,7 +10,7 @@ import java.util.List; /** * Created by snoop on 17. 7. 27. */ -@Service("MetaInfraTypeService") +@Service("MetaHistoryTypeService") public class MetaHistoryTypeService { @Autowired @@ -19,4 +19,12 @@ public class MetaHistoryTypeService { public List readAll() { return this.hisotyTypeDAO.findAll(); } + + public MetaHistoryType regist(MetaHistoryType type) { + return this.hisotyTypeDAO.save(type); + } + + public List registAll(List types) { + return this.hisotyTypeDAO.save(types); + } } diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index 902a811..9bc55b0 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -377,6 +377,22 @@ INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VAL INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( 31,'2017-07-27 15:29:48.634',24,63); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +1,'2017-08-23 13:28:26.966','Member'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +2,'2017-08-23 13:28:26.966','Probe'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +3,'2017-08-23 13:28:26.966','Discovery'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +4,'2017-08-23 13:28:26.966','Target'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +5,'2017-08-23 13:28:26.966','Crawler'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +6,'2017-08-23 13:28:26.966','Sensor'); + + + + INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( diff --git a/src/test/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeServiceTest.java b/src/test/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeServiceTest.java index b30002d..fcc3e9d 100644 --- a/src/test/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/meta/service/MetaHistoryTypeServiceTest.java @@ -2,12 +2,15 @@ package com.loafle.overflow.module.meta.service; import com.loafle.overflow.module.meta.model.MetaHistoryType; import com.loafle.overflow.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; 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 java.util.ArrayList; import java.util.List; /** @@ -21,10 +24,50 @@ public class MetaHistoryTypeServiceTest { private MetaHistoryTypeService historyTypeService; @Test + @Ignore public void readAll() throws Exception { - List historyTypes = this.historyTypeService.readAll(); + } + @Test + public void save() throws Exception { + List list = new ArrayList<>(); + + MetaHistoryType t1 = new MetaHistoryType(); + t1.setId(1); + t1.setName("Member"); + + MetaHistoryType t2 = new MetaHistoryType(); + t2.setId(2); + t2.setName("Probe"); + + MetaHistoryType t3 = new MetaHistoryType(); + t3.setId(3); + t3.setName("Discovery"); + + MetaHistoryType t4 = new MetaHistoryType(); + t4.setId(4); + t4.setName("Target"); + + MetaHistoryType t5 = new MetaHistoryType(); + t5.setId(5); + t5.setName("Crawler"); + + MetaHistoryType t6 = new MetaHistoryType(); + t6.setId(6); + t6.setName("Sensor"); + + //todo: need more + + list.add(t1); + list.add(t2); + list.add(t3); + list.add(t4); + list.add(t5); + list.add(t6); + + List result = this.historyTypeService.registAll(list); + Assert.assertEquals(result.size(), list.size()); } } \ No newline at end of file