move the id type into spec
This commit is contained in:
@@ -11,6 +11,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
// TODO: remove this dep
|
||||
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
"go.senan.xyz/gonic/server/mime"
|
||||
)
|
||||
|
||||
@@ -46,6 +49,10 @@ type Artist struct {
|
||||
AlbumCount int `sql:"-"`
|
||||
}
|
||||
|
||||
func (a *Artist) SID() specid.ID {
|
||||
return specid.ID{Type: specid.Artist, Value: a.ID}
|
||||
}
|
||||
|
||||
func (a *Artist) IndexName() string {
|
||||
if len(a.NameUDec) > 0 {
|
||||
return a.NameUDec
|
||||
@@ -85,6 +92,18 @@ type Track struct {
|
||||
TagBrainzID string `sql:"default: null"`
|
||||
}
|
||||
|
||||
func (t *Track) SID() specid.ID {
|
||||
return specid.ID{Type: specid.Track, Value: t.ID}
|
||||
}
|
||||
|
||||
func (t *Track) AlbumSID() specid.ID {
|
||||
return specid.ID{Type: specid.Album, Value: t.AlbumID}
|
||||
}
|
||||
|
||||
func (t *Track) ArtistSID() specid.ID {
|
||||
return specid.ID{Type: specid.Artist, Value: t.ArtistID}
|
||||
}
|
||||
|
||||
func (t *Track) Ext() string {
|
||||
longExt := path.Ext(t.Filename)
|
||||
if len(longExt) < 1 {
|
||||
@@ -157,6 +176,14 @@ type Album struct {
|
||||
ReceivedTags bool `gorm:"-"`
|
||||
}
|
||||
|
||||
func (a *Album) SID() specid.ID {
|
||||
return specid.ID{Type: specid.Album, Value: a.ID}
|
||||
}
|
||||
|
||||
func (a *Album) ParentSID() specid.ID {
|
||||
return specid.ID{Type: specid.Album, Value: a.ParentID}
|
||||
}
|
||||
|
||||
func (a *Album) IndexRightPath() string {
|
||||
if len(a.RightPathUDec) > 0 {
|
||||
return a.RightPathUDec
|
||||
|
||||
Reference in New Issue
Block a user