feat: 锁定文章需填写锁定理由,编辑器显示锁定理由
- Post 模型新增 LockReason 字段,锁定必填理由,解锁清空 - PostLockRequest DTO:reason 必填,1-500字 - Admin JS:锁定操作弹出 prompt 要求填写理由 - 编辑器锁定横幅显示"锁定理由:XXX",理由为空时不显示该行
This commit is contained in:
@ -116,7 +116,13 @@ func (ctrl *AdminPostController) Lock(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctrl.postService.Lock(uint(id)); err != nil {
|
||||
var req model.PostLockRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.Error(c, http.StatusBadRequest, "请填写锁定理由")
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctrl.postService.Lock(uint(id), req.Reason); err != nil {
|
||||
if errors.Is(err, common.ErrPostNotFound) || errors.Is(err, common.ErrPostCannotLock) {
|
||||
common.Error(c, http.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
|
||||
@ -42,7 +42,7 @@ type adminPostUseCase interface {
|
||||
ListPendingRevisions(keyword string, page, pageSize int) ([]model.Post, int64, error)
|
||||
Approve(postID uint) error
|
||||
Reject(postID uint, reason string) error
|
||||
Lock(postID uint) error
|
||||
Lock(postID uint, reason string) error
|
||||
Unlock(postID uint) error
|
||||
Restore(postID uint) error
|
||||
}
|
||||
|
||||
@ -154,7 +154,6 @@ func (ctrl *StudioController) WritePage(c *gin.Context) {
|
||||
"Post": post,
|
||||
"ActiveTab": "write",
|
||||
"ExtraCSS": "/static/css/studio.css",
|
||||
"StatusNames": common.PostStatusDisplayNames,
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user