| 392 | return s.store.Count(ctx) |
| 393 | } |
| 394 | func (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 | } |
| 422 | func (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{})) |