media
parent
188d45cd9a
commit
f96f30d290
|
@ -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')
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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> {
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
Reference in New Issue