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

Method Search

module/catalogue/iml.go:551–580  ·  view source on GitHub ↗
(ctx context.Context, keyword string)

Source from the content-addressed store, hash-verified

549}
550
551func (i *imlCatalogueModule) Search(ctx context.Context, keyword string) ([]*catalogue_dto.Item, error) {
552 all, err := i.catalogueService.List(ctx)
553 if err != nil {
554 return nil, err
555 }
556 if keyword == "" {
557 parentMap := make(map[string][]*catalogue.Catalogue)
558 nodeMap := make(map[string]*catalogue.Catalogue)
559 for _, v := range all {
560 if _, ok := parentMap[v.Parent]; !ok {
561 parentMap[v.Parent] = make([]*catalogue.Catalogue, 0)
562 }
563 parentMap[v.Parent] = append(parentMap[v.Parent], v)
564 nodeMap[v.Id] = v
565 }
566 return treeItems("", parentMap), nil
567 }
568
569 catalogues, err := i.catalogueService.Search(ctx, keyword, nil)
570 if err != nil {
571 return nil, err
572 }
573 if i.root == nil {
574 // 初始化
575 i.root = NewRoot(all)
576 }
577 items := make([]*catalogue_dto.Item, 0, len(catalogues))
578
579 return items, nil
580}
581
582func (i *imlCatalogueModule) Create(ctx context.Context, input *catalogue_dto.CreateCatalogue) error {
583 parent := ""

Callers

nothing calls this directly

Calls 4

treeItemsFunction · 0.85
NewRootFunction · 0.85
ListMethod · 0.65
SearchMethod · 0.65

Tested by

no test coverage detected