fix: 锁定机制不再改变帖子状态,锁定与退回独立
- Post 模型新增 IsLocked 字段,与 Status 解耦 - Lock 仅设 IsLocked=true(不改 Status),已通过帖子锁定后仍公开可见 - Unlock 仅设 IsLocked=false(不改 Status) - Update/EditPage 编辑检查改用 IsLocked 而非 Status==locked - Reject 与 Lock 独立,可单独退回或锁定+退回组合使用 - 新增 ErrPostCannotLock 错误哨兵 - 前端模板编辑按钮/锁定标识基于 IsLocked 渲染
This commit is contained in:
@ -13,7 +13,6 @@
|
||||
<option value="pending" {{if eq .Status "pending"}}selected{{end}}>待审核</option>
|
||||
<option value="approved" {{if eq .Status "approved"}}selected{{end}}>已发布</option>
|
||||
<option value="rejected" {{if eq .Status "rejected"}}selected{{end}}>已退回</option>
|
||||
<option value="locked" {{if eq .Status "locked"}}selected{{end}}>已锁定</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">搜索</button>
|
||||
</form>
|
||||
@ -43,7 +42,7 @@
|
||||
<td>{{.ID}}</td>
|
||||
<td><a href="/posts/{{.ID}}" target="_blank" class="post-link">{{.Title}}</a></td>
|
||||
<td>{{if .AuthorName}}{{.AuthorName}}({{.UserID}}){{else}}UID{{.UserID}}{{end}}</td>
|
||||
<td><span class="status-badge status-{{.Status}}">{{index $.StatusNames .Status}}</span></td>
|
||||
<td><span class="status-badge status-{{.Status}}">{{index $.StatusNames .Status}}</span>{{if .IsLocked}} <span class="status-badge status-locked">已锁定</span>{{end}}</td>
|
||||
<td>{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
|
||||
<td class="actions-cell">
|
||||
<div class="action-btns">
|
||||
@ -54,10 +53,10 @@
|
||||
{{if eq .Status "approved"}}
|
||||
<button class="btn btn-sm btn-warning post-reject" data-id="{{.ID}}">退回</button>
|
||||
{{end}}
|
||||
{{if and (ne .Status "locked") (ne .Status "pending")}}
|
||||
{{if and (not .IsLocked) (ne .Status "pending")}}
|
||||
<button class="btn btn-sm btn-danger post-lock" data-id="{{.ID}}">锁定</button>
|
||||
{{end}}
|
||||
{{if eq .Status "locked"}}
|
||||
{{if .IsLocked}}
|
||||
<button class="btn btn-sm btn-success post-unlock" data-id="{{.ID}}">解锁</button>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user