Merge branch 'master' of github.com:esensar/steleks_web_app

master
esensar 2017-03-23 22:50:48 +01:00
commit 3e42d2e5aa
6 changed files with 106 additions and 16 deletions

View File

@ -23,6 +23,7 @@ repositories {
dependencies {
compile("users")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile('org.springframework.boot:spring-boot-starter-data-jpa')
runtime('com.h2database:h2')

View File

@ -5,15 +5,9 @@ package ba.steleks.repository;
import ba.steleks.repository.model.Event;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import java.util.List;
@RepositoryRestResource(collectionResourceRel = "events", path = "events")
public interface EventsJpaRepository extends PagingAndSortingRepository<Event, Long> {
Event save(Event event);
List<Event> findAll();
Event findOne(Long ID);
List<Event> findByTitle(String title);
}

View File

@ -0,0 +1,12 @@
package ba.steleks.repository;
import ba.steleks.repository.model.Media;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* Created by admin on 23/03/2017.
*/
public interface MediaJpaRepository extends PagingAndSortingRepository<Media, Long> {
}

View File

@ -1,10 +1,8 @@
package ba.steleks.repository.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;
/**
* Created by admin on 22/03/2017.
@ -20,9 +18,13 @@ public class Event {
private String longText;
private Timestamp dateTime;
private int duration;
private String createdById;
private long createdById;
private String eventType;
@ManyToMany
@JoinColumn
private Set<Media> mediaSet;
protected Event() {}
public long getId() {
@ -73,11 +75,11 @@ public class Event {
this.duration = duration;
}
public String getCreatedById() {
public long getCreatedById() {
return createdById;
}
public void setCreatedById(String createdById) {
public void setCreatedById(long createdById) {
this.createdById = createdById;
}

View File

@ -0,0 +1,58 @@
package ba.steleks.repository.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.sql.Date;
/**
* Created by admin on 23/03/2017.
*/
@Entity
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String contentUrl;
private Date creationDate;
private String createdById;
public Media() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getContentUrl() {
return contentUrl;
}
public void setContentUrl(String contentUrl) {
this.contentUrl = contentUrl;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
public String getCreatedById() {
return createdById;
}
public void setCreatedById(String createdById) {
this.createdById = createdById;
}
}

View File

@ -1 +1,24 @@
server.port = 9000
spring.datasource.url = jdbc:mysql://localhost:3306/events
spring.datasource.username = root
spring.datasource.password = 1DvaTri!
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager)
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect