live-forum/.kiro/specs/post-reply-permission/tasks.md
2026-03-24 11:27:37 +08:00

94 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Implementation Plan: 帖子回复权限设置Post Reply Permission
## Overview
本计划将帖子回复权限功能分解为数据库、后端 API、前端 API 封装、前端页面四个部分,按顺序实现。每个阶段完成后进行 Checkpoint 验证。
## Tasks
- [x] 1. 数据库变更与实体更新
- [x] 1.1 创建数据库迁移脚本
-`server/webapi/数据库脚本/` 下创建 SQL 脚本
- 为 T_Posts 表新增 `AllowReply BIT NOT NULL DEFAULT 1` 字段
- _Requirements: 4.1_
- [x] 1.2 修改 T_Posts 实体类
-`LiveForum.Model/Model/T_Posts.cs` 中新增 `AllowReply` 属性,默认值 `true`
- _Requirements: 4.1_
- [x] 2. 后端 API 实现
- [x] 2.1 修改发帖相关 DTO 和服务
-`LiveForum.Model/Dto/Posts/PublishPostsDtos.cs``PublishPostsReq` 中新增 `AllowReply` 字段,默认 `true`
- 修改 `LiveForum.Service/Posts/PostsService.cs``PublishPosts` 方法,将 `AllowReply` 写入数据库
- _Requirements: 1.4, 1.5, 4.2_
- [x] 2.2 修改帖子详情 DTO
-`LiveForum.Model/Dto/Posts/GetPostDetailDtos.cs``PostDetailDto` 中新增 `AllowReply` 字段
- 修改 `PostsService``GetPostDetail` 方法,返回 `AllowReply`
- _Requirements: 4.3_
- [x] 2.3 新增修改回复权限接口
-`LiveForum.Model/Dto/Posts/` 下创建 `UpdateReplyPermissionDtos.cs`,包含 `UpdateReplyPermissionReq``UpdateReplyPermissionRespDto`
-`LiveForum.IService/Posts/IPostsService.cs` 中新增 `UpdateReplyPermission` 方法签名
-`LiveForum.Service/Posts/PostsService.cs` 中实现 `UpdateReplyPermission` 方法:查询帖子、校验作者身份、更新 `AllowReply` 字段
-`LiveForum.WebApi/Controllers/PostsController.cs` 中新增 `[Authorize] POST UpdateReplyPermission` 接口
- _Requirements: 4.4, 4.5, 4.6_
- [x] 2.4 修改发表评论接口增加权限校验
-`LiveForum.Service/Posts/PostCommentsService.cs``PublishPostComments` 方法中,增加对目标帖子 `AllowReply` 字段的检查
-`AllowReply = false`,返回错误信息「该帖子不允许回复」
- _Requirements: 5.1, 5.2, 5.3_
- [ ]* 2.5 编写属性测试 - 发布帖子回复权限 Round-Trip
- **Property 1: 发布帖子回复权限 Round-Trip**
-`LiveForum.Tests` 中创建 `PostReplyPermissionPropertyTests.cs`
- 使用 FsCheck.Xunit 生成随机 `allowReply` 布尔值,验证发布→查询的 round-trip 一致性
- **Validates: Requirements 1.4, 1.5, 4.2, 4.3**
- [ ]* 2.6 编写属性测试 - 非作者修改权限被拒绝
- **Property 3: 非作者修改权限被拒绝**
- 生成随机非作者用户ID验证调用 `UpdateReplyPermission` 返回权限不足错误,且帖子 `AllowReply` 值不变
- **Validates: Requirements 4.5, 4.6**
- [ ]* 2.7 编写属性测试 - 评论权限与 AllowReply 状态一致
- **Property 4: 评论权限与 AllowReply 状态一致**
- 生成随机 `allowReply` 状态和评论内容,验证评论接口行为与 `AllowReply` 一致
- **Validates: Requirements 5.1, 5.2, 5.3**
- [x] 3. Checkpoint - 后端 API 完成
- 确保所有测试通过,如有问题请提出。
- [x] 4. 前端 API 封装
- [x] 4.1 修改 AppServer.js
- 新增 `apiUrl_Live_UpdateReplyPermission` 配置
- 新增 `UpdateReplyPermission(postId, allowReply)` 方法
- 修改 `PublishPosts` 方法,增加 `allowReply` 参数并传递到请求体
- _Requirements: 1.4, 2.8_
- [x] 5. 前端发帖页修改
- [x] 5.1 修改 post-page.vue 添加回复权限复选框
-`data` 中新增 `allowReply: false`(默认未勾选)
- 在图片上传区域下方添加圆形复选框,文案「允许帖子内回复」
- 修改 `handlePublish` 方法,将 `allowReply` 传递给 `PublishPosts` 调用
- _Requirements: 1.1, 1.2, 1.3, 1.4_
- [x] 6. 前端帖子详情页修改
- [x] 6.1 添加「……」按钮和 More_Menu
- 在帖子详情页右上角(仅发帖人可见)添加「……」按钮
- 点击弹出底部 action sheet包含「帖子内回复设置」、「举报」、「取消」三个选项
- _Requirements: 2.1, 2.2, 2.3, 2.4_
- [x] 6.2 实现 Reply_Setting_Popup 弹窗
- 点击「帖子内回复设置」后关闭 action sheet弹出居中 dialog
- dialog 显示标题「帖子内回复设置」和两个按钮:「允许帖子内回复」、「不允许帖子内回复」
- 当前状态以蓝色填充+白色文字高亮,未选中以白色背景+描边显示
- 点击不同选项时调用 `UpdateReplyPermission` 接口,成功后关闭弹窗并更新本地 `detailsData.allowReply`
- _Requirements: 2.5, 2.6, 2.7, 2.8, 2.9_
- [x] 6.3 实现评论输入区域权限状态切换
-`detailsData.allowReply === false` 时:灰色背景、显示「不可回复」提示文字、不可点击
-`detailsData.allowReply === true` 时:保持现有行为
- 已有评论列表始终正常显示
- _Requirements: 3.1, 3.2, 3.3, 3.4, 3.5_
- [x] 7. Final Checkpoint - 全部完成
- 确保所有功能正常,如有问题请提出。
## Notes
- 标记 `*` 的子任务为可选属性测试任务,可跳过以加快 MVP 进度
- 每个任务关联了具体的需求编号,便于追溯
- 属性测试使用 FsCheck.Xunit验证核心正确性属性
- Checkpoint 用于阶段性验证,确保增量开发的正确性