Big LedisDB refactoring
This commit is contained in:
+1
-24
@@ -3,32 +3,9 @@ package models
|
||||
type Album struct {
|
||||
Id string
|
||||
Name string
|
||||
ArtistId string
|
||||
ArtistId string `parent:"artist"`
|
||||
CoverArtPath string
|
||||
Year int
|
||||
Compilation bool
|
||||
Rating int
|
||||
MediaFiles map[string]bool
|
||||
}
|
||||
|
||||
func (a *Album) AdMediaFiles(mfs ...*MediaFile) {
|
||||
for _, mf := range mfs {
|
||||
a.MediaFiles[mf.Id] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Album) AddMediaFiles(mfs ...interface{}) {
|
||||
if a.MediaFiles == nil {
|
||||
a.MediaFiles = make(map[string]bool)
|
||||
}
|
||||
for _, v := range mfs {
|
||||
switch v := v.(type) {
|
||||
case *MediaFile:
|
||||
a.MediaFiles[v.Id] = true
|
||||
case map[string]bool:
|
||||
for k, _ := range v {
|
||||
a.MediaFiles[k] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,20 +20,4 @@ func NoArticle(name string) string {
|
||||
}
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (a *Artist) AddAlbums(albums ...interface{}) {
|
||||
if a.Albums == nil {
|
||||
a.Albums = make(map[string]bool)
|
||||
}
|
||||
for _, v := range albums {
|
||||
switch v := v.(type) {
|
||||
case *Album:
|
||||
a.Albums[v.Id] = true
|
||||
case map[string]bool:
|
||||
for k, _ := range v {
|
||||
a.Albums[k] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ type MediaFile struct {
|
||||
Album string
|
||||
Artist string
|
||||
AlbumArtist string
|
||||
AlbumId string `parent:"album"`
|
||||
Compilation bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
|
||||
Reference in New Issue
Block a user