diff --git a/src/main/java/com/loafle/bridge/Application.java b/src/main/java/com/loafle/bridge/Application.java index 306d20c..a105015 100644 --- a/src/main/java/com/loafle/bridge/Application.java +++ b/src/main/java/com/loafle/bridge/Application.java @@ -29,6 +29,8 @@ public class Application { ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet()); registration.addUrlMappings("/console/*"); registration.addInitParameter("webAllowOthers", "true"); + + return registration; } diff --git a/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveriyHistoryController.java b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveriyHistoryController.java new file mode 100644 index 0000000..1d9659a --- /dev/null +++ b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveriyHistoryController.java @@ -0,0 +1,31 @@ +package com.loafle.bridge.discoveryHistory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * Created by root on 16. 11. 15. + */ +@RestController +public class DiscoveriyHistoryController { + + @Autowired + DiscoveryHistoryRepository discoveryHistoryRepository; + + + @RequestMapping(value = "discoveryHistory/{id}", method = RequestMethod.GET) + public DiscoveryHistory getDiscoveryHistory(@PathVariable(name = "id")long id) throws Exception { + return this.discoveryHistoryRepository.findOne(id); + } + + @RequestMapping(value = "discoveryHistory/", method = RequestMethod.GET) + public List getDiscoveryHistoryList() throws Exception { + return this.discoveryHistoryRepository.findAll(); + } + +} diff --git a/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistory.java b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistory.java new file mode 100644 index 0000000..64bd487 --- /dev/null +++ b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistory.java @@ -0,0 +1,61 @@ +package com.loafle.bridge.discoveryHistory; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 16. 11. 15. + */ +@Entity +public class DiscoveryHistory +{ + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, updatable = false) + private Date startDate; + @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", updatable = false) + private Date endDate; + + @Column(name="RESULT", nullable=false) + private Boolean result; + +// private null DiscoveryZone; + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public Boolean getResult() { + return result; + } + + public void setResult(Boolean result) { + this.result = result; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepository.java b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistoryRepository.java similarity index 75% rename from src/main/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepository.java rename to src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistoryRepository.java index e8822c1..f58434b 100644 --- a/src/main/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepository.java +++ b/src/main/java/com/loafle/bridge/discoveryHistory/DiscoveryHistoryRepository.java @@ -1,6 +1,6 @@ -package com.loafle.bridge.discoveryHistory.repository; +package com.loafle.bridge.discoveryHistory; -import com.loafle.bridge.discoveryHistory.entity.DiscoveryHistory; +import com.loafle.bridge.discoveryHistory.DiscoveryHistory; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; diff --git a/src/main/java/com/loafle/bridge/discoveryHistory/controller/DiscoveriyHistoryController.java b/src/main/java/com/loafle/bridge/discoveryHistory/controller/DiscoveriyHistoryController.java deleted file mode 100644 index e301c67..0000000 --- a/src/main/java/com/loafle/bridge/discoveryHistory/controller/DiscoveriyHistoryController.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.loafle.bridge.discoveryHistory.controller; - -/** - * Created by root on 16. 11. 15. - */ -public class DiscoveriyHistoryController { -} diff --git a/src/main/java/com/loafle/bridge/discoveryHistory/entity/DiscoveryHistory.java b/src/main/java/com/loafle/bridge/discoveryHistory/entity/DiscoveryHistory.java deleted file mode 100644 index 11af482..0000000 --- a/src/main/java/com/loafle/bridge/discoveryHistory/entity/DiscoveryHistory.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.loafle.bridge.discoveryHistory.entity; - -import javax.persistence.*; -import java.util.Date; - -/** - * Created by root on 16. 11. 15. - */ -@Entity -public class DiscoveryHistory -{ - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(name = "START_AT", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false) - private Date startAt; - @Column(name = "END_AT", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false) - private Date endAt; - - @Column(name="RESULT", nullable=false) - private Boolean result; - -// private null DiscoveryZone; - - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public Date getStartAt() { - return startAt; - } - - public void setStartAt(Date startAt) { - this.startAt = startAt; - } - - public Date getEndAt() { - return endAt; - } - - public void setEndAt(Date endAt) { - this.endAt = endAt; - } - - public Boolean getResult() { - return result; - } - - public void setResult(Boolean result) { - this.result = result; - } - - -} \ No newline at end of file diff --git a/src/main/java/com/loafle/bridge/discoveryzone/entity/DiscoveryZone.java b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java similarity index 60% rename from src/main/java/com/loafle/bridge/discoveryzone/entity/DiscoveryZone.java rename to src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java index e16286a..9f38b31 100644 --- a/src/main/java/com/loafle/bridge/discoveryzone/entity/DiscoveryZone.java +++ b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java @@ -1,7 +1,9 @@ -package com.loafle.bridge.discoveryzone.entity; +package com.loafle.bridge.discoveryzone; /** * Created by root on 16. 11. 15. */ public class DiscoveryZone { + + } diff --git a/src/main/java/com/loafle/bridge/discoveryzone/controller/DiscoveryZoneController.java b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneController.java similarity index 61% rename from src/main/java/com/loafle/bridge/discoveryzone/controller/DiscoveryZoneController.java rename to src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneController.java index 39dc7cb..e3613eb 100644 --- a/src/main/java/com/loafle/bridge/discoveryzone/controller/DiscoveryZoneController.java +++ b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneController.java @@ -1,4 +1,4 @@ -package com.loafle.bridge.discoveryzone.controller; +package com.loafle.bridge.discoveryzone; /** * Created by root on 16. 11. 15. diff --git a/src/main/java/com/loafle/bridge/discoveryzone/repository/DiscoveryZoneRepository.java b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneRepository.java similarity index 61% rename from src/main/java/com/loafle/bridge/discoveryzone/repository/DiscoveryZoneRepository.java rename to src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneRepository.java index b6694aa..f3ad74e 100644 --- a/src/main/java/com/loafle/bridge/discoveryzone/repository/DiscoveryZoneRepository.java +++ b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZoneRepository.java @@ -1,4 +1,4 @@ -package com.loafle.bridge.discoveryzone.repository; +package com.loafle.bridge.discoveryzone; /** * Created by root on 16. 11. 15. diff --git a/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java b/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java new file mode 100644 index 0000000..5c4c4c8 --- /dev/null +++ b/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java @@ -0,0 +1,47 @@ +package com.loafle.bridge.discoveryHistory.repository; + +import com.loafle.bridge.Application; +import com.loafle.bridge.discoveryHistory.DiscoveryHistory; +import com.loafle.bridge.discoveryHistory.DiscoveryHistoryRepository; +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; + +/** + * Created by snoop on 16. 11. 15. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = Application.class) +public class DiscoveryHistoryRepositoryTest { + + @Autowired + DiscoveryHistoryRepository discoveryHistoryRepository; + + + + + @Test + public void inserTest() { + + DiscoveryHistory discoveryHistory = new DiscoveryHistory(); + +// discoveryHistory.setStartAt(new Date()); +// discoveryHistory.setEndAt(new Date()); + discoveryHistory.setResult(true); + + + discoveryHistoryRepository.save(discoveryHistory); + + System.out.println("iiiiiiiiiiiiiiiiiiiiiiiii" + discoveryHistory.getId()); + + System.out.println("discoveryHistoryRepository = "); + + for (DiscoveryHistory dh : discoveryHistoryRepository.findAll() ) { + System.out.println("dh.getId() = " + dh.getStartDate()); + } + + } + +} \ No newline at end of file