Project events into json with medis and type
parent
71da53ffd6
commit
d4f86c106c
|
@ -19,12 +19,17 @@ public class Event {
|
|||
private Timestamp dateTime;
|
||||
private int duration;
|
||||
private long createdById;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn
|
||||
private EventType eventType;
|
||||
|
||||
@ManyToMany
|
||||
@JoinColumn
|
||||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
|
||||
@JoinTable(
|
||||
name = "event_media_set",
|
||||
joinColumns=@JoinColumn(name = "event_id"),
|
||||
inverseJoinColumns = @JoinColumn(name="media_set_id")
|
||||
)
|
||||
private Set<Media> mediaSet;
|
||||
|
||||
protected Event() {}
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
package ba.steleks.repository;
|
||||
|
||||
import ba.steleks.model.Event;
|
||||
import ba.steleks.repository.projection.EventProjection;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
||||
@RepositoryRestResource(excerptProjection = EventProjection.class)
|
||||
public interface EventsJpaRepository extends PagingAndSortingRepository<Event, Long> {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package ba.steleks.repository.projection;/**
|
||||
* Created by ensar on 10/06/17.
|
||||
*/
|
||||
|
||||
import ba.steleks.model.Event;
|
||||
import ba.steleks.model.EventType;
|
||||
import ba.steleks.model.Media;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
@Projection(name = "eventProjection", types = { Event.class })
|
||||
public interface EventProjection {
|
||||
String getTitle();
|
||||
String getShortText();
|
||||
String getLongText();
|
||||
Timestamp getDateTime();
|
||||
int getDuration();
|
||||
long getCreatedById();
|
||||
EventType getEventType();
|
||||
Set<Media> getMediaSet();
|
||||
}
|
Reference in New Issue