MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / Create

Method Create

module/catalogue/iml.go:582–610  ·  view source on GitHub ↗
(ctx context.Context, input *catalogue_dto.CreateCatalogue)

Source from the content-addressed store, hash-verified

580}
581
582func (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
612func (i *imlCatalogueModule) Edit(ctx context.Context, id string, input *catalogue_dto.EditCatalogue) error {
613 err := i.catalogueService.Save(ctx, id, &catalogue.EditCatalogue{

Callers

nothing calls this directly

Calls 4

NewRootFunction · 0.85
CreateMethod · 0.65
ListMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected