(ctx context.Context)
| 403 | } |
| 404 | |
| 405 | func (i *imlServiceModule) ExportAll(ctx context.Context) ([]*service_dto.ExportService, error) { |
| 406 | services, err := i.serviceService.ServiceList(ctx) |
| 407 | if err != nil { |
| 408 | return nil, err |
| 409 | } |
| 410 | serviceIds := utils.SliceToSlice(services, func(s *service.Service) string { |
| 411 | return s.Id |
| 412 | }) |
| 413 | serviceTags, err := i.serviceTagService.List(ctx, serviceIds, nil) |
| 414 | if err != nil { |
| 415 | return nil, err |
| 416 | } |
| 417 | tagMap, err := i.tagService.Map(ctx) |
| 418 | if err != nil { |
| 419 | return nil, err |
| 420 | } |
| 421 | serviceTagMap := make(map[string][]string) |
| 422 | for _, st := range serviceTags { |
| 423 | if _, ok := tagMap[st.Tid]; !ok { |
| 424 | continue |
| 425 | } |
| 426 | if _, ok := serviceTagMap[st.Sid]; !ok { |
| 427 | serviceTagMap[st.Sid] = make([]string, 0) |
| 428 | } |
| 429 | serviceTagMap[st.Sid] = append(serviceTagMap[st.Sid], tagMap[st.Tid].Name) |
| 430 | } |
| 431 | |
| 432 | items := make([]*service_dto.ExportService, 0, len(services)) |
| 433 | for _, s := range services { |
| 434 | info := &service_dto.ExportService{ |
| 435 | Id: s.Id, |
| 436 | Name: s.Name, |
| 437 | Prefix: s.Prefix, |
| 438 | Description: s.Description, |
| 439 | Team: s.Team, |
| 440 | ServiceType: s.ServiceType.String(), |
| 441 | Catalogue: s.Catalogue, |
| 442 | Logo: s.Logo, |
| 443 | } |
| 444 | |
| 445 | if tags, ok := serviceTagMap[s.Id]; ok { |
| 446 | info.Tags = tags |
| 447 | } |
| 448 | items = append(items, info) |
| 449 | } |
| 450 | return items, nil |
| 451 | } |
| 452 | |
| 453 | func (i *imlServiceModule) searchMyServices(ctx context.Context, teamId string, keyword string) ([]*service.Service, error) { |
| 454 | userID := utils.UserId(ctx) |
nothing calls this directly
no test coverage detected