mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-12-16 14:15:30 +00:00
Added DB models
This commit is contained in:
@@ -8,33 +8,33 @@ import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func RecordsFromReihentitel(app core.App, reihen xmlmodels.Reihentitel) ([]*core.Record, error) {
|
||||
func RecordsFromReihentitel(app core.App, reihen xmlmodels.Reihentitel) ([]*dbmodels.Series, error) {
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.SERIES_TABLE)
|
||||
records := make([]*core.Record, 0, len(reihen.Reihen))
|
||||
records := make([]*dbmodels.Series, 0, len(reihen.Reihen))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return records, err
|
||||
}
|
||||
|
||||
for i := 0; i < len(reihen.Reihen); i++ {
|
||||
record := core.NewRecord(collection)
|
||||
record := dbmodels.NewSeries(core.NewRecord(collection))
|
||||
reihe := reihen.Reihen[i]
|
||||
if reihe.Titel == "" {
|
||||
record.Set(dbmodels.SERIES_NAME_FIELD, reihe.Sortiername)
|
||||
record.SetTitle(NormalizeString(reihe.Sortiername))
|
||||
} else {
|
||||
record.Set(dbmodels.SERIES_NAME_FIELD, reihe.Titel)
|
||||
record.SetTitle(NormalizeString(reihe.Titel))
|
||||
}
|
||||
|
||||
record.Set(dbmodels.REFERENCES_FIELD, NormalizeString(reihe.Nachweis))
|
||||
record.Set(dbmodels.ANNOTATION_FIELD, NormalizeString(reihe.Anmerkungen))
|
||||
record.Set(dbmodels.SERIES_FREQUENCY_FIELD, "jährlich")
|
||||
record.Set(dbmodels.MUSENALMID_FIELD, reihe.ID)
|
||||
record.SetReferences(NormalizeString(reihe.Nachweis))
|
||||
record.SetAnnotation(NormalizeString(reihe.Anmerkungen))
|
||||
record.SetFrequency("jährlich")
|
||||
record.SetMusenalmID(reihe.ID)
|
||||
|
||||
n := record.GetString(dbmodels.SERIES_NAME_FIELD)
|
||||
n := record.Title()
|
||||
if n == "" {
|
||||
record.Set(dbmodels.EDITSTATE_FIELD, dbmodels.EDITORSTATE_VALUES[1])
|
||||
record.SetEditState(dbmodels.EDITORSTATE_VALUES[1])
|
||||
} else {
|
||||
record.Set(dbmodels.EDITSTATE_FIELD, dbmodels.EDITORSTATE_VALUES[len(dbmodels.EDITORSTATE_VALUES)-1])
|
||||
record.SetEditState(dbmodels.EDITORSTATE_VALUES[len(dbmodels.EDITORSTATE_VALUES)-1])
|
||||
}
|
||||
|
||||
records = append(records, record)
|
||||
|
||||
Reference in New Issue
Block a user