fix: 评论系统全量检查修复(7 项 Gap 全部修复)
- Delete 权限:新增 requesterID/isAdmin 参数,Service 层鉴权(仅本人/管理员可删)
- 通知内容:改用 GetUsernameByID 显示真实用户名,非数字 UID
- SearchUsers:Repository 返回 exp,Service 调用 GetLevelByExp 计算等级
- 通知高亮:Notification 新增 CommentID 字段,消息链接支持 #comment-{id}
- 已删除提示:前端 hash 检测 + 3 秒超时 Toast "该评论已不存在"
- Admin CSS:移除不存在的 comments.css 引用
- 错误哨兵:改用 common.ErrCommentNotFound/ErrCommentEmpty/PermissionDenied
This commit is contained in:
@ -26,7 +26,7 @@ func NewNotificationService(repo notifRepo) *NotificationService {
|
||||
}
|
||||
|
||||
// Create 创建消息
|
||||
func (s *NotificationService) Create(userID uint, notifyType, title, content string, relatedID *uint) error {
|
||||
func (s *NotificationService) Create(userID uint, notifyType, title, content string, relatedID, commentID *uint) error {
|
||||
n := &model.Notification{
|
||||
UserID: userID,
|
||||
NotifyType: notifyType,
|
||||
@ -34,6 +34,7 @@ func (s *NotificationService) Create(userID uint, notifyType, title, content str
|
||||
Content: content,
|
||||
IsRead: false,
|
||||
RelatedID: relatedID,
|
||||
CommentID: commentID,
|
||||
}
|
||||
return s.repo.Create(n)
|
||||
}
|
||||
@ -92,7 +93,7 @@ func (s *NotificationService) NotifyAuditApproved(userID uint, auditType string,
|
||||
_ = s.Create(userID, model.NotifyAuditApproved,
|
||||
"审核已通过",
|
||||
"你的"+typeName+"修改已通过审核",
|
||||
&relatedID)
|
||||
&relatedID, nil)
|
||||
}
|
||||
|
||||
// NotifyAuditRejected 审核拒绝通知
|
||||
@ -108,14 +109,14 @@ func (s *NotificationService) NotifyAuditRejected(userID uint, auditType, reason
|
||||
_ = s.Create(userID, model.NotifyAuditRejected,
|
||||
"审核未通过",
|
||||
content,
|
||||
&relatedID)
|
||||
&relatedID, nil)
|
||||
}
|
||||
|
||||
// NotifyPostApproved 稿件审核通过通知
|
||||
func (s *NotificationService) NotifyPostApproved(userID uint, postTitle string, postID uint) {
|
||||
title := "稿件审核通过"
|
||||
content := "你的稿件《" + postTitle + "》已通过审核,现已公开发布"
|
||||
_ = s.Create(userID, model.NotifyPostApproved, title, content, &postID)
|
||||
_ = s.Create(userID, model.NotifyPostApproved, title, content, &postID, nil)
|
||||
}
|
||||
|
||||
// NotifyPostRejected 稿件审核拒绝通知
|
||||
@ -125,5 +126,5 @@ func (s *NotificationService) NotifyPostRejected(userID uint, postTitle, reason
|
||||
if reason != "" {
|
||||
content += ",理由:" + reason
|
||||
}
|
||||
_ = s.Create(userID, model.NotifyPostRejected, title, content, &postID)
|
||||
_ = s.Create(userID, model.NotifyPostRejected, title, content, &postID, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user