forked from airsonic-advanced/airsonic-advanced
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #645 from kagemomiji/issue401-ordering-playlist
#401 Fix random ordering issue of playlist
- Loading branch information
Showing
14 changed files
with
621 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
airsonic-main/src/main/java/org/airsonic/player/domain/PlaylistMediaFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package org.airsonic.player.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
|
||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "playlist_file") | ||
public class PlaylistMediaFile implements Serializable { | ||
|
||
public PlaylistMediaFile() { | ||
} | ||
|
||
public PlaylistMediaFile(Playlist playlist, MediaFile mediaFile, int orderIndex) { | ||
this.playlist = playlist; | ||
this.mediaFile = mediaFile; | ||
this.orderIndex = orderIndex; | ||
} | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "playlist_id") | ||
private Playlist playlist; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "media_file_id") | ||
private MediaFile mediaFile; | ||
|
||
@Column(name = "order_index") | ||
private int orderIndex; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public Playlist getPlaylist() { | ||
return playlist; | ||
} | ||
|
||
public void setPlaylist(Playlist playlist) { | ||
this.playlist = playlist; | ||
} | ||
|
||
public MediaFile getMediaFile() { | ||
return mediaFile; | ||
} | ||
|
||
public void setMediaFile(MediaFile mediaFile) { | ||
this.mediaFile = mediaFile; | ||
} | ||
|
||
public int getOrderIndex() { | ||
return orderIndex; | ||
} | ||
|
||
public void setOrderIndex(int orderIndex) { | ||
this.orderIndex = orderIndex; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof PlaylistMediaFile)) return false; | ||
|
||
PlaylistMediaFile that = (PlaylistMediaFile) o; | ||
|
||
if (orderIndex != that.orderIndex) return false; | ||
if (id != null ? !id.equals(that.id) : that.id != null) return false; | ||
if (playlist != null ? !playlist.equals(that.playlist) : that.playlist != null) return false; | ||
return mediaFile != null ? mediaFile.equals(that.mediaFile) : that.mediaFile == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = id != null ? id.hashCode() : 0; | ||
result = 31 * result + (playlist != null ? playlist.hashCode() : 0); | ||
result = 31 * result + (mediaFile != null ? mediaFile.hashCode() : 0); | ||
result = 31 * result + orderIndex; | ||
return result; | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
airsonic-main/src/main/java/org/airsonic/player/repository/PlaylistMediaFileRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.airsonic.player.repository; | ||
|
||
import org.airsonic.player.domain.PlaylistMediaFile; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface PlaylistMediaFileRepository extends JpaRepository<PlaylistMediaFile, Integer> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
airsonic-main/src/main/resources/liquibase/11.1/add-order-index-column-playlist-file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> | ||
|
||
<!-- 1. Check if track_number column exists, if not, add it --> | ||
<changeSet id="add-order-index-to-playlist-file" author="kagemomiji"> | ||
<preConditions onFail="MARK_RAN"> | ||
<not> | ||
<columnExists tableName="playlist_file" columnName="order_index"/> | ||
</not> | ||
</preConditions> | ||
<addColumn tableName="playlist_file"> | ||
<column name="order_index" type="int" defaultValue="-1"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</addColumn> | ||
<rollback> | ||
<dropColumn tableName="playlist_file" columnName="order_index"/> | ||
</rollback> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.