package json import ( "sync" "time" "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db" ) type World struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` Authors []*Author `json:"authors"` Media []*Media `json:"media"` Version string `json:"version"` Compatibility Compatibility `json:"compatibility"` Scripts []string `json:"scripts"` Esmodules []string `json:"esmodules"` Styles []*Style `json:"styles"` Languages []*Language `json:"languages"` Packs []*Pack `json:"packs"` PackFolders []*Folder `json:"packFolders"` Relationships Relationships `json:"relationships"` Socket bool `json:"socket"` Protected bool `json:"protected"` Exclusive bool `json:"exclusive"` PersistentStorage bool `json:"persistentStorage"` System string `json:"system"` Background string `json:"background"` JoinTheme string `json:"joinTheme"` CoreVersion string `json:"coreVersion"` SystemVersion string `json:"systemVersion"` LastPlayed string `json:"lastPlayed"` Playtime int `json:"playtime"` NextSession time.Time `json:"nextSession"` Demo Demo `json:"demo"` Availability int `json:"availability"` Locked bool `json:"locked"` Owned bool `json:"owned"` Tags []string `json:"tags"` HasStorage bool `json:"hasStorage"` // Flags any `json:"flags"` } func (w *World) ToDB(dest *db.World) bool { if dest == nil { return false } dest.ID = w.ID dest.Title = w.Title dest.Description = w.Description dest.Version = w.Version dest.Socket = w.Socket dest.Protected = w.Protected dest.Exclusive = w.Exclusive dest.PersistentStorage = w.PersistentStorage dest.System = w.System dest.Background = w.Background dest.JoinTheme = w.JoinTheme dest.CoreVersion = w.CoreVersion dest.SystemVersion = w.SystemVersion dest.LastPlayed = w.LastPlayed dest.Playtime = w.Playtime dest.NextSession = w.NextSession dest.Availability = w.Availability dest.Locked = w.Locked dest.Owned = w.Owned dest.HasStorage = w.HasStorage copy(dest.Scripts, w.Scripts) copy(dest.Esmodules, w.Esmodules) copy(dest.Tags, w.Tags) w.Compatibility.ToDB(&dest.Compatibility) w.Relationships.ToDB(&dest.Relationships) wg := sync.WaitGroup{} go CopySliceToDBParallel(&wg, &dest.Authors, w.Authors) go CopySliceToDBParallel(&wg, &dest.Media, w.Media) go CopySliceToDBParallel(&wg, &dest.Styles, w.Styles) go CopySliceToDBParallel(&wg, &dest.Languages, w.Languages) go CopySliceToDBParallel(&wg, &dest.Packs, w.Packs) go CopySliceToDBParallel(&wg, &dest.PackFolders, w.PackFolders) wg.Wait() return true } type Demo struct { SourceZip any `json:"sourceZip"` }