MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / SearchPosts

Method SearchPosts

internal/service/search.go:46–71  ·  view source on GitHub ↗
(ctx context.Context, expression string)

Source from the content-addressed store, hash-verified

44 return comments, nil
45}
46func (s *searchService) SearchPosts(ctx context.Context, expression string) ([]domain.PostSearch, error) {
47 // 将表达式拆分为关键字数组
48 keywords := strings.Split(expression, " ")
49
50 var eg errgroup.Group
51 var posts []domain.PostSearch
52
53 eg.Go(func() error {
54 // 搜索帖子
55 foundPosts, err := s.repo.SearchPosts(ctx, keywords)
56 if err != nil {
57 return err
58 }
59
60 posts = foundPosts
61
62 return nil
63 })
64
65 // 等待所有并发任务完成
66 if err := eg.Wait(); err != nil {
67 return nil, err
68 }
69
70 return posts, nil
71}
72
73func (s *searchService) SearchUsers(ctx context.Context, expression string) ([]domain.UserSearch, error) {
74 // 将表达式拆分为关键字数组

Callers

nothing calls this directly

Calls 1

SearchPostsMethod · 0.65

Tested by

no test coverage detected