feat: @搜索优先展示已关注用户,结果限制最多5条
- SearchUsersByLevel SQL新增LEFT JOIN user_follows,按已关注优先+exp降序 - SearchUsers/followerUID参数贯穿repo→service→controller - 继续输入时前端自动重新搜索新关键词
This commit is contained in:
@ -190,9 +190,9 @@ func (s *CommentService) ListAllComments(keyword string, showDeleted bool, page,
|
||||
return rows, total, err
|
||||
}
|
||||
|
||||
// SearchUsers 搜索LV2+用户(用于@艾特悬浮窗)
|
||||
func (s *CommentService) SearchUsers(keyword string) ([]model.UserSearchResult, error) {
|
||||
rows, err := s.repo.SearchUsersByLevel(keyword, 2, 10)
|
||||
// SearchUsers 搜索LV2+用户(用于@艾特悬浮窗),已关注优先,最多5条
|
||||
func (s *CommentService) SearchUsers(keyword string, followerUID uint) ([]model.UserSearchResult, error) {
|
||||
rows, err := s.repo.SearchUsersByLevel(keyword, 2, 5, followerUID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("搜索用户失败: %w", err)
|
||||
}
|
||||
@ -219,7 +219,7 @@ func (s *CommentService) parseMentions(commentID uint, body string) {
|
||||
continue
|
||||
}
|
||||
seen[username] = true
|
||||
rows, _ := s.repo.SearchUsersByLevel(username, 2, 1)
|
||||
rows, _ := s.repo.SearchUsersByLevel(username, 2, 1, 0)
|
||||
if len(rows) > 0 {
|
||||
_ = s.repo.CreateMention(&model.CommentMention{
|
||||
CommentID: commentID,
|
||||
|
||||
@ -155,7 +155,7 @@ type commentStore interface {
|
||||
CreateMention(mention *model.CommentMention) error
|
||||
FindPostIDByComment(commentID uint) (uint, error)
|
||||
FindPostAuthorID(postID uint) (uint, error)
|
||||
SearchUsersByLevel(keyword string, minLevel, limit int) ([]struct {
|
||||
SearchUsersByLevel(keyword string, minLevel, limit int, followerUID uint) ([]struct {
|
||||
UID uint
|
||||
Username string
|
||||
Avatar string
|
||||
|
||||
Reference in New Issue
Block a user