package json import ( "sync" "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db" ) type System struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` Authors []*Author `json:"authors"` URL string `json:"url"` License string `json:"license"` Bugs string `json:"bugs"` Changelog string `json:"changelog"` Media []*Media `json:"media"` Version string `json:"version"` Compatibility Compatibility `json:"compatibility"` Scripts []string `json:"scripts"` Esmodules []string `json:"esmodules"` Packs []*Pack `json:"packs"` Styles []*Style `json:"styles"` Languages []*Language `json:"languages"` PackFolders []*Folder `json:"packFolders"` Relationships Relationships `json:"relationships"` Socket bool `json:"socket"` Manifest string `json:"manifest"` Download string `json:"download"` Protected bool `json:"protected"` Exclusive bool `json:"exclusive"` PersistentStorage bool `json:"persistentStorage"` DocumentTypes DocumentTypes `json:"documentTypes"` Background string `json:"background"` Grid Grid `json:"grid"` PrimaryTokenAttribute string `json:"primaryTokenAttribute"` Availability int `json:"availability"` Locked bool `json:"locked"` Owned bool `json:"owned"` Tags []string `json:"tags"` HasStorage bool `json:"hasStorage"` // SystemFlags SystemFlags `json:"flags"` } func (s *System) ToDB(dest *db.System) bool { if dest == nil { return false } dest.ID = s.ID dest.Title = s.Title dest.Description = s.Description dest.URL = s.URL dest.License = s.License dest.Bugs = s.Bugs dest.Changelog = s.Changelog dest.Version = s.Version dest.Socket = s.Socket dest.Manifest = s.Manifest dest.Download = s.Download dest.Protected = s.Protected dest.Exclusive = s.Exclusive dest.PersistentStorage = s.PersistentStorage dest.Background = s.Background dest.PrimaryTokenAttribute = s.PrimaryTokenAttribute dest.Availability = s.Availability dest.Locked = s.Locked dest.Owned = s.Owned dest.HasStorage = s.HasStorage copy(dest.Scripts, s.Scripts) copy(dest.Esmodules, s.Esmodules) copy(dest.Tags, s.Tags) s.Compatibility.ToDB(&dest.Compatibility) s.Relationships.ToDB(&dest.Relationships) s.DocumentTypes.ToDB(&dest.DocumentTypes) s.Grid.ToDB(&dest.Grid) wg := sync.WaitGroup{} go CopySliceToDBParallel(&wg, &dest.Authors, s.Authors) go CopySliceToDBParallel(&wg, &dest.Media, s.Media) go CopySliceToDBParallel(&wg, &dest.Styles, s.Styles) go CopySliceToDBParallel(&wg, &dest.Languages, s.Languages) go CopySliceToDBParallel(&wg, &dest.Packs, s.Packs) go CopySliceToDBParallel(&wg, &dest.PackFolders, s.PackFolders) wg.Wait() return true }