feat: 评论系统补充功能完成——图片上传、后台管理、通知跳转高亮
- 评论图片上传(LV4+,经验≥1500),JPEG/PNG 自动转 WebP,二进制搜索质量优化 - 后台评论管理页面,支持关键词搜索、分页、删除,侧边栏新增入口 - 通知跳转高亮:评论通知 RelatedID 改为 postID,消息页链接到 #comments,前端自动滚动 - 新增 adminCommentUseCase/commentStore 接口(遵循 ISP),AdminCommentRow 移至 model 层 - 前端 @mention 联想/图片上传光标插入/评论展开收起/内联回复交互完善
This commit is contained in:
@ -58,13 +58,13 @@ func (s *CommentService) CreateRoot(userID uint, postID uint, body string) (*mod
|
||||
// 解析 @ 提及
|
||||
s.parseMentions(comment.ID, body)
|
||||
|
||||
// 通知文章作者(评论者 ≠ 作者)
|
||||
// 通知文章作者(评论者 ≠ 作者),RelatedID 存 postID 以便消息页生成跳转链接
|
||||
if s.notifier != nil && userID != postAuthorID {
|
||||
commenterUID, _ := s.repo.GetUserUIDByID(userID)
|
||||
s.notifier.Create(postAuthorID, model.NotifyComment,
|
||||
"新评论",
|
||||
fmt.Sprintf("%s 评论了你的文章", commenterUID),
|
||||
&comment.ID)
|
||||
&comment.PostID)
|
||||
}
|
||||
|
||||
return comment, nil
|
||||
@ -106,13 +106,13 @@ func (s *CommentService) CreateReply(userID uint, parentID uint, body string) (*
|
||||
// 解析 @ 提及
|
||||
s.parseMentions(comment.ID, body)
|
||||
|
||||
// 通知被回复者(不自己回复自己)
|
||||
// 通知被回复者(不自己回复自己),RelatedID 存 postID 以便消息页生成跳转链接
|
||||
if s.notifier != nil && parent.UserID != userID {
|
||||
commenterUID, _ := s.repo.GetUserUIDByID(userID)
|
||||
s.notifier.Create(parent.UserID, model.NotifyCommentReply,
|
||||
"新回复",
|
||||
fmt.Sprintf("%s 回复了你的评论", commenterUID),
|
||||
&comment.ID)
|
||||
&parent.PostID)
|
||||
}
|
||||
|
||||
return comment, nil
|
||||
@ -159,6 +159,17 @@ func (s *CommentService) ListReplies(rootID uint) ([]model.Comment, error) {
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// ListAllComments 后台评论列表(分页+搜索)
|
||||
func (s *CommentService) ListAllComments(keyword string, showDeleted bool, page, pageSize int) ([]model.AdminCommentRow, int64, error) {
|
||||
p := common.Pagination{Page: page, PageSize: pageSize}
|
||||
p.DefaultPagination()
|
||||
rows, total, err := s.repo.ListAllComments(keyword, showDeleted, p.Offset(), p.PageSize)
|
||||
if rows == nil {
|
||||
rows = []model.AdminCommentRow{}
|
||||
}
|
||||
return rows, total, err
|
||||
}
|
||||
|
||||
// SearchUsers 搜索LV3+用户(用于@艾特)
|
||||
func (s *CommentService) SearchUsers(keyword string) ([]model.UserSearchResult, error) {
|
||||
rows, err := s.repo.SearchUsersByLevel(keyword, 3, 10)
|
||||
|
||||
Reference in New Issue
Block a user