feat: 文章锁定/解锁时触发系统通知

- 新增 NotifyPostLocked/NotifyPostUnlocked 通知类型
- Lock/Unlock 方法执行后通过 notifier 发送通知给作者
- 锁定时通知含锁定理由,解锁时通知已解除锁定
- 新增类型归入稿件审核分类和 system tab
This commit is contained in:
2026-06-02 22:53:46 +08:00
parent b0a1ff3c3f
commit ea2f196ff7
4 changed files with 43 additions and 3 deletions

View File

@ -163,7 +163,14 @@ func (s *PostService) Lock(postID uint, reason string) error {
}
post.IsLocked = true
post.LockReason = reason
return s.repo.Update(post)
if err := s.repo.Update(post); err != nil {
return err
}
// 通知作者稿件被锁定
if s.notifier != nil {
s.notifier.NotifyPostLocked(post.UserID, post.Title, reason, post.ID)
}
return nil
}
// Unlock 解锁:清除 IsLocked 标志,恢复可编辑
@ -177,7 +184,14 @@ func (s *PostService) Unlock(postID uint) error {
}
post.IsLocked = false
post.LockReason = ""
return s.repo.Update(post)
if err := s.repo.Update(post); err != nil {
return err
}
// 通知作者稿件被解除锁定
if s.notifier != nil {
s.notifier.NotifyPostUnlocked(post.UserID, post.Title, post.ID)
}
return nil
}
// Restore 恢复软删除