MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / Search

Method Search

service/cluster/cluster.go:394–421  ·  view source on GitHub ↗
(ctx context.Context, keyword string, clusterId ...string)

Source from the content-addressed store, hash-verified

392 return s.store.Count(ctx)
393}
394func (s *imlClusterService) Search(ctx context.Context, keyword string, clusterId ...string) ([]*Cluster, error) {
395 wheres := make([]string, 0, 2)
396 value := make([]interface{}, 0, 3)
397 if keyword != "" {
398 wheres = append(wheres, "(`name` like ? or `resume` like ? or `uuid` like ?)")
399 value = append(value, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
400 }
401
402 if len(clusterId) > 0 {
403 if len(clusterId) == 1 {
404 wheres = append(wheres, "`uuid` = ?")
405 value = append(value, clusterId[0])
406 } else {
407 wheres = append(wheres, "`uuid` in (?)")
408 value = append(value, clusterId)
409 }
410
411 }
412 if len(wheres) == 0 {
413 return s.List(ctx)
414 }
415 where := strings.Join(wheres, " and ")
416 list, err := s.store.ListQuery(ctx, where, value, "update_at desc")
417 if err != nil {
418 return nil, err
419 }
420 return utils.SliceToSlice(list, FromEntity), nil
421}
422func (s *imlClusterService) List(ctx context.Context, clusterIds ...string) ([]*Cluster, error) {
423 if len(clusterIds) == 0 {
424 list, err := s.store.List(ctx, make(map[string]interface{}))

Callers

nothing calls this directly

Calls 1

ListMethod · 0.95

Tested by

no test coverage detected