feat: @搜索优先展示已关注用户,结果限制最多5条
- SearchUsersByLevel SQL新增LEFT JOIN user_follows,按已关注优先+exp降序 - SearchUsers/followerUID参数贯穿repo→service→controller - 继续输入时前端自动重新搜索新关键词
This commit is contained in:
@ -41,7 +41,7 @@ func (ctrl *CommentController) Delete(c *gin.Context) {
|
||||
|
||||
// SearchUsers GET /api/users/search?q=keyword
|
||||
func (ctrl *CommentController) SearchUsers(c *gin.Context) {
|
||||
_, _, ok := common.GetGinUser(c)
|
||||
uid, _, ok := common.GetGinUser(c)
|
||||
if !ok {
|
||||
common.Error(c, http.StatusUnauthorized, "请先登录")
|
||||
return
|
||||
@ -53,7 +53,7 @@ func (ctrl *CommentController) SearchUsers(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
users, err := ctrl.commentService.SearchUsers(q)
|
||||
users, err := ctrl.commentService.SearchUsers(q, uid)
|
||||
if err != nil {
|
||||
common.Error(c, http.StatusInternalServerError, "搜索用户失败")
|
||||
return
|
||||
|
||||
@ -115,7 +115,7 @@ type commentUseCase interface {
|
||||
Delete(commentID uint, requesterID uint, isAdmin bool) error
|
||||
ListRootComments(postID uint, page, pageSize int) ([]model.Comment, int64, error)
|
||||
ListReplies(rootID uint) ([]model.Comment, error)
|
||||
SearchUsers(keyword string) ([]model.UserSearchResult, error)
|
||||
SearchUsers(keyword string, followerUID uint) ([]model.UserSearchResult, error)
|
||||
}
|
||||
|
||||
// reactionUseCase ReactionController 对 ReactionService 的最小依赖(ISP:4 个方法)
|
||||
|
||||
Reference in New Issue
Block a user