fix: 锁定按钮改为随时可用,不联动审核状态
- 前端:锁定按钮仅受 IsLocked 控制,移除 status!=pending 的条件 - 后端:Lock 方法移除 pending 状态的阻止,锁定状态独立
This commit is contained in:
@ -155,15 +155,12 @@ func (s *PostService) Reject(postID uint, reason string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lock 锁定:设置 IsLocked 标志,禁止编辑,不改变帖子发布状态
|
// Lock 锁定:设置 IsLocked 标志,禁止编辑,不改变帖子发布状态
|
||||||
|
// 锁定状态独立于审核状态,任何状态的帖子均可锁定
|
||||||
func (s *PostService) Lock(postID uint, reason string) error {
|
func (s *PostService) Lock(postID uint, reason string) error {
|
||||||
post, err := s.findPost(postID)
|
post, err := s.findPost(postID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 待审核帖子不允许锁定(审核流程中)
|
|
||||||
if post.Status == model.PostStatusPending {
|
|
||||||
return common.ErrPostCannotLock
|
|
||||||
}
|
|
||||||
post.IsLocked = true
|
post.IsLocked = true
|
||||||
post.LockReason = reason
|
post.LockReason = reason
|
||||||
return s.repo.Update(post)
|
return s.repo.Update(post)
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
<button class="btn btn-sm btn-success post-approve" data-id="{{.ID}}">通过修订</button>
|
<button class="btn btn-sm btn-success post-approve" data-id="{{.ID}}">通过修订</button>
|
||||||
<button class="btn btn-sm btn-warning post-reject" data-id="{{.ID}}">退回修订</button>
|
<button class="btn btn-sm btn-warning post-reject" data-id="{{.ID}}">退回修订</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and (not .IsLocked) (ne .Status "pending")}}
|
{{if not .IsLocked}}
|
||||||
<button class="btn btn-sm btn-danger post-lock" data-id="{{.ID}}">锁定</button>
|
<button class="btn btn-sm btn-danger post-lock" data-id="{{.ID}}">锁定</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .IsLocked}}
|
{{if .IsLocked}}
|
||||||
|
|||||||
Reference in New Issue
Block a user