75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package json
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
|
|
)
|
|
|
|
type Pack struct {
|
|
Name string `json:"name"`
|
|
Label string `json:"label"`
|
|
Banner string `json:"banner"`
|
|
Path string `json:"path"`
|
|
Type string `json:"type"`
|
|
System string `json:"system"`
|
|
Ownership Ownership `json:"ownership"`
|
|
PackageType string `json:"packageType,omitempty"`
|
|
PackageName string `json:"packageName,omitempty"`
|
|
Id string `json:"id,omitempty"`
|
|
Index []*Index `json:"index"`
|
|
Folders []*PackFolder `json:"folders"`
|
|
// SystemPacksFlags SystemPacksFlags `json:"flags"`
|
|
}
|
|
|
|
func (p *Pack) ToDB(dest *db.Pack) bool {
|
|
if dest == nil {
|
|
return false
|
|
}
|
|
|
|
dest.Name = p.Name
|
|
dest.Label = p.Label
|
|
dest.Banner = p.Banner
|
|
dest.Path = p.Path
|
|
dest.Type = p.Type
|
|
dest.System = p.System
|
|
p.Ownership.ToDB(&dest.Ownership)
|
|
dest.PackageType = p.PackageType
|
|
dest.PackageName = p.PackageName
|
|
dest.ID = p.Id
|
|
|
|
wg := sync.WaitGroup{}
|
|
go CopySliceToDBParallel(&wg, &dest.Index, p.Index)
|
|
go CopySliceToDBParallel(&wg, &dest.Folders, p.Folders)
|
|
wg.Wait()
|
|
|
|
return true
|
|
}
|
|
|
|
type PackFolder struct {
|
|
ID string `json:"_id"`
|
|
Color any `json:"color"`
|
|
Description string `json:"description"`
|
|
Folder any `json:"folder"`
|
|
Name string `json:"name"`
|
|
Sort int `json:"sort"`
|
|
Sorting string `json:"sorting"`
|
|
Type string `json:"type"`
|
|
// Packs0FoldersFlags any `json:"flags"`
|
|
}
|
|
|
|
func (p *PackFolder) ToDB(dest *db.PackFolder) bool {
|
|
if dest == nil {
|
|
return false
|
|
}
|
|
|
|
dest.ID = p.ID
|
|
dest.Description = p.Description
|
|
dest.Name = p.Name
|
|
dest.Sort = p.Sort
|
|
dest.Sorting = p.Sorting
|
|
dest.Type = p.Type
|
|
|
|
return true
|
|
}
|