feat: 锁定文章需填写锁定理由,编辑器显示锁定理由

- Post 模型新增 LockReason 字段,锁定必填理由,解锁清空
- PostLockRequest DTO:reason 必填,1-500字
- Admin JS:锁定操作弹出 prompt 要求填写理由
- 编辑器锁定横幅显示"锁定理由:XXX",理由为空时不显示该行
This commit is contained in:
2026-05-31 20:10:55 +08:00
parent b658eeb8e9
commit 968e8af8a3
8 changed files with 23 additions and 6 deletions

View File

@ -341,7 +341,7 @@ func (s *PostService) Reject(postID uint, reason string) error {
}
// Lock 锁定:设置 IsLocked 标志,禁止编辑,不改变帖子发布状态
func (s *PostService) Lock(postID uint) error {
func (s *PostService) Lock(postID uint, reason string) error {
post, err := s.findPost(postID)
if err != nil {
return err
@ -351,6 +351,7 @@ func (s *PostService) Lock(postID uint) error {
return common.ErrPostCannotLock
}
post.IsLocked = true
post.LockReason = reason
return s.repo.Update(post)
}
@ -364,6 +365,7 @@ func (s *PostService) Unlock(postID uint) error {
return common.ErrPostCannotUnlock
}
post.IsLocked = false
post.LockReason = ""
return s.repo.Update(post)
}