package graph import ( "context" "encoding/json" "forge.cadoles.com/Cadoles/daddy/internal/orm" "gitlab.com/wpetit/goweb/middleware/container" "forge.cadoles.com/Cadoles/daddy/internal/model" errs "github.com/pkg/errors" ) func handleCreateDecisionSupportFile(ctx context.Context, changes *model.DecisionSupportFileChanges) (*model.DecisionSupportFile, error) { ctn := container.Must(ctx) db := orm.Must(ctn).DB() repo := model.NewDSFRepository(db) dsf, err := repo.Create(ctx, changes) if err != nil { return nil, errs.WithStack(err) } return dsf, nil } func handleUpdateDecisionSupportFile(ctx context.Context, id string, changes *model.DecisionSupportFileChanges) (*model.DecisionSupportFile, error) { ctn := container.Must(ctx) db := orm.Must(ctn).DB() repo := model.NewDSFRepository(db) dsf, err := repo.Update(ctx, id, changes) if err != nil { return nil, errs.WithStack(err) } return dsf, nil } func handleDecisionSupportFiles(ctx context.Context, filter *model.DecisionSupportFileFilter) ([]*model.DecisionSupportFile, error) { ctn := container.Must(ctx) db := orm.Must(ctn).DB() repo := model.NewDSFRepository(db) return repo.Search(ctx, filter) } func handleSections(ctx context.Context, dsf *model.DecisionSupportFile) (map[string]interface{}, error) { sections := make(map[string]interface{}) if err := json.Unmarshal(dsf.Sections.RawMessage, §ions); err != nil { return nil, errs.WithStack(err) } return sections, nil }