finish world initialization, set up init on startup and on shutdown, move all models to main directory
This commit is contained in:
51
internal/foundry/models/json/relationships.go
Normal file
51
internal/foundry/models/json/relationships.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Relationships struct {
|
||||
Systems []*RelationshipsData `json:"systems,omitempty"`
|
||||
Requires []*RelationshipsData `json:"requires,omitempty"`
|
||||
Recommends []*RelationshipsData `json:"recommends,omitempty"`
|
||||
Conflicts []*RelationshipsData `json:"conflicts,omitempty"`
|
||||
// RelationshipsFlags RelationshipsFlags `json:"flags"`
|
||||
}
|
||||
|
||||
func (r *Relationships) ToDB(dest *db.Relationships) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &dest.Systems, r.Systems)
|
||||
CopySliceToDBParallel(&wg, &dest.Requires, r.Requires)
|
||||
CopySliceToDBParallel(&wg, &dest.Recommends, r.Recommends)
|
||||
CopySliceToDBParallel(&wg, &dest.Conflicts, r.Conflicts)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type RelationshipsData struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Manifest string `json:"manifest"`
|
||||
Compatibility Compatibility `json:"compatibility"`
|
||||
}
|
||||
|
||||
func (r *RelationshipsData) ToDB(dest *db.RelationshipsData) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Key = r.Id
|
||||
dest.Type = r.Type
|
||||
dest.Manifest = r.Manifest
|
||||
|
||||
r.Compatibility.ToDB(&dest.Compatibility)
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user