mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 13:50:28 +05:30
Add playlist object.
This commit is contained in:
parent
11845f26fc
commit
056d61f2d2
@ -2,6 +2,8 @@ package me.kavin.piped.utils;
|
||||
|
||||
import me.kavin.piped.consts.Constants;
|
||||
import me.kavin.piped.utils.obj.db.Channel;
|
||||
import me.kavin.piped.utils.obj.db.Playlist;
|
||||
import me.kavin.piped.utils.obj.db.PlaylistVideo;
|
||||
import me.kavin.piped.utils.obj.db.PubSub;
|
||||
import me.kavin.piped.utils.obj.db.User;
|
||||
import me.kavin.piped.utils.obj.db.Video;
|
||||
@ -21,8 +23,9 @@ public class DatabaseSessionFactory {
|
||||
configuration.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
|
||||
configuration.configure();
|
||||
|
||||
sessionFactory = configuration.addAnnotatedClass(User.class).addAnnotatedClass(Video.class)
|
||||
.addAnnotatedClass(Channel.class).addAnnotatedClass(PubSub.class).buildSessionFactory();
|
||||
sessionFactory = configuration.addAnnotatedClass(User.class).addAnnotatedClass(Channel.class)
|
||||
.addAnnotatedClass(Video.class).addAnnotatedClass(PubSub.class).addAnnotatedClass(Playlist.class)
|
||||
.addAnnotatedClass(PlaylistVideo.class).buildSessionFactory();
|
||||
}
|
||||
|
||||
public static final Session createSession() {
|
||||
|
95
src/main/java/me/kavin/piped/utils/obj/db/Playlist.java
Normal file
95
src/main/java/me/kavin/piped/utils/obj/db/Playlist.java
Normal file
@ -0,0 +1,95 @@
|
||||
package me.kavin.piped.utils.obj.db;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "playlists", indexes = { @Index(columnList = "playlist_id", name = "playlists_playlist_id_idx") })
|
||||
public class Playlist {
|
||||
|
||||
public Playlist() {
|
||||
}
|
||||
|
||||
public Playlist(String name, List<PlaylistVideo> videos, String thumbnail) {
|
||||
this.name = name;
|
||||
this.videos = videos;
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "playlist_id")
|
||||
private UUID playlist_id;
|
||||
|
||||
@Column(name = "name", length = 100)
|
||||
private String name;
|
||||
|
||||
@Column(name = "thumbnail", length = 255)
|
||||
private String thumbnail;
|
||||
|
||||
@Column(name = "owner")
|
||||
private long owner;
|
||||
|
||||
@ElementCollection(fetch = FetchType.LAZY)
|
||||
@OneToMany(targetEntity = PlaylistVideo.class)
|
||||
@Column(name = "videos")
|
||||
private List<PlaylistVideo> videos;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UUID getPlaylistId() {
|
||||
return playlist_id;
|
||||
}
|
||||
|
||||
public void setPlaylistId(UUID playlist_id) {
|
||||
this.playlist_id = playlist_id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<PlaylistVideo> getVideos() {
|
||||
return videos;
|
||||
}
|
||||
|
||||
public void setVideos(List<PlaylistVideo> videos) {
|
||||
this.videos = videos;
|
||||
}
|
||||
|
||||
public String getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public void setThumbnail(String thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public long getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(long owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
84
src/main/java/me/kavin/piped/utils/obj/db/PlaylistVideo.java
Normal file
84
src/main/java/me/kavin/piped/utils/obj/db/PlaylistVideo.java
Normal file
@ -0,0 +1,84 @@
|
||||
package me.kavin.piped.utils.obj.db;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "playlist_videos", indexes = { @Index(columnList = "id", name = "playlist_videos_id_idx"),
|
||||
@Index(columnList = "uploader_id", name = "playlist_videos_uploader_id_idx") })
|
||||
public class PlaylistVideo {
|
||||
|
||||
public PlaylistVideo() {
|
||||
}
|
||||
|
||||
public PlaylistVideo(String id, String title, long duration, String thumbnail, Channel channel) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.duration = duration;
|
||||
this.thumbnail = thumbnail;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name = "id", unique = true, length = 16)
|
||||
private String id;
|
||||
|
||||
@Column(name = "title", length = 120)
|
||||
private String title;
|
||||
|
||||
@Column(name = "duration")
|
||||
private long duration;
|
||||
|
||||
@Column(name = "thumbnail", length = 150)
|
||||
private String thumbnail;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "uploader_id")
|
||||
private Channel channel;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public void setThumbnail(String thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user