add new models, change migration files, prepare to add all new tables from models
This commit is contained in:
93
internal/foundry/temp_models/json/module.go
Normal file
93
internal/foundry/temp_models/json/module.go
Normal file
@@ -0,0 +1,93 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
|
||||
)
|
||||
|
||||
type Module struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Authors []*Author `json:"authors"`
|
||||
URL string `json:"url,omitempty"`
|
||||
License string `json:"license,omitempty"`
|
||||
Readme string `json:"readme,omitempty"`
|
||||
Bugs string `json:"bugs,omitempty"`
|
||||
Changelog string `json:"changelog,omitempty"`
|
||||
Media []*Media `json:"media"`
|
||||
Version string `json:"version"`
|
||||
Compatibility Compatibility `json:"compatibility,omitempty"`
|
||||
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"`
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
Download string `json:"download,omitempty"`
|
||||
Protected bool `json:"protected"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
PersistentStorage bool `json:"persistentStorage"`
|
||||
CoreTranslation bool `json:"coreTranslation"`
|
||||
Library bool `json:"library"`
|
||||
DocumentTypes DocumentTypes `json:"documentTypes"`
|
||||
Availability int `json:"availability"`
|
||||
Locked bool `json:"locked"`
|
||||
Owned bool `json:"owned"`
|
||||
Tags []string `json:"tags"`
|
||||
HasStorage bool `json:"hasStorage"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
// ModulesFlags ModulesFlags `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Module) ToDB(dest *db.Module) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.ID = m.ID
|
||||
dest.Title = m.Title
|
||||
dest.Description = m.Description
|
||||
dest.URL = m.URL
|
||||
dest.License = m.License
|
||||
dest.Readme = m.Readme
|
||||
dest.Bugs = m.Bugs
|
||||
dest.Changelog = m.Changelog
|
||||
dest.Version = m.Version
|
||||
dest.Socket = m.Socket
|
||||
dest.Manifest = m.Manifest
|
||||
dest.Download = m.Download
|
||||
dest.Protected = m.Protected
|
||||
dest.Exclusive = m.Exclusive
|
||||
dest.PersistentStorage = m.PersistentStorage
|
||||
dest.CoreTranslation = m.CoreTranslation
|
||||
dest.Library = m.Library
|
||||
dest.Availability = m.Availability
|
||||
dest.Locked = m.Locked
|
||||
dest.Owned = m.Owned
|
||||
dest.HasStorage = m.HasStorage
|
||||
dest.Active = m.Active
|
||||
|
||||
copy(dest.Scripts, m.Scripts)
|
||||
copy(dest.Esmodules, m.Esmodules)
|
||||
copy(dest.Tags, m.Tags)
|
||||
|
||||
m.Compatibility.ToDB(&dest.Compatibility)
|
||||
m.Relationships.ToDB(&dest.Relationships)
|
||||
m.DocumentTypes.ToDB(&dest.DocumentTypes)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
go CopySliceToDBParallel(&wg, &dest.Authors, m.Authors)
|
||||
go CopySliceToDBParallel(&wg, &dest.Media, m.Media)
|
||||
go CopySliceToDBParallel(&wg, &dest.Styles, m.Styles)
|
||||
go CopySliceToDBParallel(&wg, &dest.Languages, m.Languages)
|
||||
go CopySliceToDBParallel(&wg, &dest.Packs, m.Packs)
|
||||
go CopySliceToDBParallel(&wg, &dest.PackFolders, m.PackFolders)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user