package
This commit is contained in:
snoop 2016-11-16 12:43:34 +09:00
parent d4e0049681
commit cd4aa2a085
10 changed files with 148 additions and 73 deletions

View File

@ -29,6 +29,8 @@ public class Application {
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
registration.addUrlMappings("/console/*");
registration.addInitParameter("webAllowOthers", "true");
return registration;
}

View File

@ -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<DiscoveryHistory> getDiscoveryHistoryList() throws Exception {
return this.discoveryHistoryRepository.findAll();
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -1,7 +0,0 @@
package com.loafle.bridge.discoveryHistory.controller;
/**
* Created by root on 16. 11. 15.
*/
public class DiscoveriyHistoryController {
}

View File

@ -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;
}
}

View File

@ -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 {
}

View File

@ -1,4 +1,4 @@
package com.loafle.bridge.discoveryzone.controller;
package com.loafle.bridge.discoveryzone;
/**
* Created by root on 16. 11. 15.

View File

@ -1,4 +1,4 @@
package com.loafle.bridge.discoveryzone.repository;
package com.loafle.bridge.discoveryzone;
/**
* Created by root on 16. 11. 15.

View File

@ -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());
}
}
}