| 512 | } |
| 513 | |
| 514 | func (i *imlCatalogueModule) recurseUpdateSort(ctx context.Context, parent string, sorts []*catalogue_dto.SortItem) error { |
| 515 | for index, item := range sorts { |
| 516 | s := index |
| 517 | err := i.catalogueService.Save(ctx, item.Id, &catalogue.EditCatalogue{ |
| 518 | Parent: &parent, |
| 519 | Sort: &s, |
| 520 | }) |
| 521 | if err != nil { |
| 522 | return err |
| 523 | } |
| 524 | if len(item.Children) < 1 { |
| 525 | continue |
| 526 | } |
| 527 | err = i.recurseUpdateSort(ctx, item.Id, item.Children) |
| 528 | if err != nil { |
| 529 | return err |
| 530 | } |
| 531 | } |
| 532 | return nil |
| 533 | } |
| 534 | |
| 535 | func (i *imlCatalogueModule) Sort(ctx context.Context, sorts []*catalogue_dto.SortItem) error { |
| 536 | return i.transaction.Transaction(ctx, func(ctx context.Context) error { |