Big LedisDB refactoring

This commit is contained in:
Deluan
2016-02-28 22:56:24 -05:00
parent 515279606a
commit 49b512fc9c
11 changed files with 105 additions and 123 deletions
+1 -24
View File
@@ -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
}
}
}
}