package json import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db" type Playlist struct { Name string `json:"name"` ID string `json:"_id"` Sounds []*Sound `json:"sounds"` Mode int `json:"mode"` Playing bool `json:"playing"` Fade int `json:"fade,omitempty"` Folder string `json:"folder"` Sorting string `json:"sorting"` Seed int `json:"seed,omitempty"` Sort int `json:"sort"` Ownership map[string]int `json:"ownership,omitempty"` Stats Stats `json:"_stats"` Description string `json:"description,omitempty"` Channel string `json:"channel"` // Flags any `json:"flags,omitempty"` } func (p *Playlist) ToDB(dest *db.Playlist) bool { if dest == nil { return false } dest.Name = p.Name dest.ID = p.ID dest.Mode = p.Mode dest.Playing = p.Playing dest.Fade = p.Fade dest.Folder = p.Folder dest.Sorting = p.Sorting dest.Seed = p.Seed dest.Sort = p.Sort dest.Description = p.Description dest.Channel = p.Channel p.Stats.ToDB(&dest.Stats) OwnershipToDB(&dest.Ownership, p.Ownership) CopySliceToDB(&dest.Sounds, p.Sounds) return true } type Sound struct { Name string `json:"name"` Path string `json:"path"` ID string `json:"_id"` Playing bool `json:"playing"` PausedTime float64 `json:"pausedTime"` Repeat bool `json:"repeat"` Volume float64 `json:"volume"` Fade int `json:"fade"` Sort int `json:"sort"` Channel string `json:"channel"` Description string `json:"description,omitempty"` // Flags any `json:"flags"` } func (s *Sound) ToDB(dest *db.Sound) bool { if dest == nil { return false } dest.Name = s.Name dest.Path = s.Path dest.ID = s.ID dest.Playing = s.Playing dest.PausedTime = s.PausedTime dest.Repeat = s.Repeat dest.Volume = s.Volume dest.Fade = s.Fade dest.Sort = s.Sort dest.Channel = s.Channel dest.Description = s.Description return true }