| 580 | } |
| 581 | |
| 582 | func (i *imlCatalogueModule) Create(ctx context.Context, input *catalogue_dto.CreateCatalogue) error { |
| 583 | parent := "" |
| 584 | if input.Parent != nil { |
| 585 | parent = *input.Parent |
| 586 | } |
| 587 | if input.Id == "" { |
| 588 | input.Id = uuid.New().String() |
| 589 | } |
| 590 | index := _sortMax |
| 591 | if input.Sort != nil { |
| 592 | index = *input.Sort |
| 593 | } |
| 594 | err := i.catalogueService.Create(ctx, &catalogue.CreateCatalogue{ |
| 595 | Id: input.Id, |
| 596 | Name: input.Name, |
| 597 | Parent: parent, |
| 598 | Sort: index, |
| 599 | }) |
| 600 | if err != nil { |
| 601 | return err |
| 602 | } |
| 603 | // 重新初始化 |
| 604 | catalogues, err := i.catalogueService.List(ctx) |
| 605 | if err != nil { |
| 606 | return err |
| 607 | } |
| 608 | i.root = NewRoot(catalogues) |
| 609 | return nil |
| 610 | } |
| 611 | |
| 612 | func (i *imlCatalogueModule) Edit(ctx context.Context, id string, input *catalogue_dto.EditCatalogue) error { |
| 613 | err := i.catalogueService.Save(ctx, id, &catalogue.EditCatalogue{ |