diff --git a/events/build.gradle b/events/build.gradle index 05de41e..dda8709 100644 --- a/events/build.gradle +++ b/events/build.gradle @@ -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') diff --git a/events/src/main/java/ba/steleks/repository/EventsJpaRepository.java b/events/src/main/java/ba/steleks/repository/EventsJpaRepository.java index 43176e7..e6a1ad6 100644 --- a/events/src/main/java/ba/steleks/repository/EventsJpaRepository.java +++ b/events/src/main/java/ba/steleks/repository/EventsJpaRepository.java @@ -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 save(Event event); - List findAll(); - Event findOne(Long ID); - List findByTitle(String title); - } diff --git a/events/src/main/java/ba/steleks/repository/MediaJpaRepository.java b/events/src/main/java/ba/steleks/repository/MediaJpaRepository.java new file mode 100644 index 0000000..b28a028 --- /dev/null +++ b/events/src/main/java/ba/steleks/repository/MediaJpaRepository.java @@ -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 { + +} diff --git a/events/src/main/java/ba/steleks/repository/model/Event.java b/events/src/main/java/ba/steleks/repository/model/Event.java index 459fc3c..efb1b1f 100644 --- a/events/src/main/java/ba/steleks/repository/model/Event.java +++ b/events/src/main/java/ba/steleks/repository/model/Event.java @@ -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 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; } diff --git a/events/src/main/java/ba/steleks/repository/model/Media.java b/events/src/main/java/ba/steleks/repository/model/Media.java new file mode 100644 index 0000000..334c96e --- /dev/null +++ b/events/src/main/java/ba/steleks/repository/model/Media.java @@ -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; + } +} diff --git a/events/src/main/resources/application.properties b/events/src/main/resources/application.properties index 6a9b0fd..edb8b0d 100644 --- a/events/src/main/resources/application.properties +++ b/events/src/main/resources/application.properties @@ -1 +1,24 @@ -server.port = 9000 \ No newline at end of file +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 \ No newline at end of file