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

Method Search

module/service/iml.go:596–629  ·  view source on GitHub ↗
(ctx context.Context, teamID string, keyword string)

Source from the content-addressed store, hash-verified

594}
595
596func (i *imlServiceModule) Search(ctx context.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error) {
597 var list []*service.Service
598 var err error
599 if teamID != "" {
600 _, err = i.teamService.Get(ctx, teamID)
601 if err != nil {
602 return nil, err
603 }
604 list, err = i.serviceService.Search(ctx, keyword, map[string]interface{}{"team": teamID, "as_server": true}, "create_at desc")
605 } else {
606 list, err = i.serviceService.Search(ctx, keyword, map[string]interface{}{"as_server": true}, "create_at desc")
607 }
608 if err != nil {
609 return nil, err
610 }
611 serviceIds := utils.SliceToSlice(list, func(s *service.Service) string {
612 return s.Id
613 })
614 overviewMap, err := i.serviceOverviewService.Map(ctx, serviceIds...)
615 if err != nil {
616 return nil, err
617 }
618 items := make([]*service_dto.ServiceItem, 0, len(list))
619 for _, model := range list {
620 item := toServiceItem(model)
621 if v, ok := overviewMap[model.Id]; ok {
622 item.ApiNum = v.ApiCount
623 item.CanDelete = v.ApiCount == 0
624 }
625
626 items = append(items, item)
627 }
628 return items, nil
629}
630
631func toServiceItem(model *service.Service) *service_dto.ServiceItem {
632 item := &service_dto.ServiceItem{

Callers

nothing calls this directly

Calls 4

toServiceItemFunction · 0.85
GetMethod · 0.65
SearchMethod · 0.65
MapMethod · 0.65

Tested by

no test coverage detected