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

Method SearchSubscribers

module/subscribe/iml.go:332–383  ·  view source on GitHub ↗
(ctx context.Context, serviceId string, keyword string)

Source from the content-addressed store, hash-verified

330}
331
332func (i *imlSubscribeModule) SearchSubscribers(ctx context.Context, serviceId string, keyword string) ([]*subscribe_dto.Subscriber, error) {
333 pInfo, err := i.serviceService.Get(ctx, serviceId)
334 if err != nil {
335 return nil, err
336 }
337
338 // 获取当前项目所有订阅方
339 list, err := i.subscribeService.ListBySubscribeStatus(ctx, serviceId, subscribe.ApplyStatusSubscribe)
340 if err != nil {
341 return nil, err
342 }
343
344 if keyword == "" {
345 items := make([]*subscribe_dto.Subscriber, 0, len(list))
346 for _, subscriber := range list {
347 items = append(items, &subscribe_dto.Subscriber{
348 Id: subscriber.Application,
349 Service: auto.UUID(subscriber.Service),
350 Subscriber: auto.UUID(subscriber.Application),
351 Team: auto.UUID(pInfo.Team),
352 Applier: auto.UUID(subscriber.Applier),
353 ApplyTime: auto.TimeLabel(subscriber.CreateAt),
354 From: subscriber.From,
355 })
356 }
357 return items, nil
358 }
359 serviceList, err := i.serviceService.Search(ctx, keyword, map[string]interface{}{
360 "service": serviceId,
361 })
362 if err != nil {
363 return nil, err
364 }
365 serviceMap := utils.SliceToMap(serviceList, func(s *service.Service) string {
366 return s.Id
367 })
368 items := make([]*subscribe_dto.Subscriber, 0, len(list))
369 for _, subscriber := range list {
370
371 if _, ok := serviceMap[subscriber.Service]; ok {
372 items = append(items, &subscribe_dto.Subscriber{
373 Id: subscriber.Id,
374 Service: auto.UUID(subscriber.Service),
375 Subscriber: auto.UUID(subscriber.Application),
376 Team: auto.UUID(pInfo.Team),
377 ApplyTime: auto.TimeLabel(subscriber.CreateAt),
378 From: subscriber.From,
379 })
380 }
381 }
382 return items, nil
383}
384
385var (
386 _ ISubscribeApprovalModule = (*imlSubscribeApprovalModule)(nil)

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
ListBySubscribeStatusMethod · 0.65
SearchMethod · 0.65

Tested by

no test coverage detected