-
Notifications
You must be signed in to change notification settings - Fork 497
[Feature]: 回收站 #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/peking-2025
Are you sure you want to change the base?
[Feature]: 回收站 #499
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/peking-2025 #499 +/- ##
======================================================
Coverage ? 82.41%
======================================================
Files ? 142
Lines ? 3616
Branches ? 461
======================================================
Hits ? 2980
Misses ? 614
Partials ? 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Reasoning Details我们正在审查一个GitHub Pull Request中的代码更改。这个PR主要实现了问卷的回收站功能,包括将问卷移至回收站、从回收站恢复、彻底删除以及回收站列表展示等功能。同时,还包括了相关的前端界面和权限控制。 首先,我们按照文件顺序逐一审查代码更改:
整体来看,这个PR实现了回收站功能的完整流程,包括后端的状态管理、接口添加、权限控制,以及前端的界面展示和操作。代码组织合理,新增了必要的测试用例。 但是,在审查过程中也发现了一些需要注意的地方:
改进建议:
因此,我们建议:
由于在PR描述中没有特别说明,我们按照当前实现(只处理用户自己创建的问卷)进行审查。因此,我们记录这个限制。 综上所述,这个PR实现了回收站的基本功能,代码质量良好,测试覆盖了新功能。但存在一些细节问题(如日期格式、回收站权限的统计和列表查询未考虑协作者)需要后续优化。 建议在合并前修复以下问题:
其他问题(如升级服务中的处理)可以暂时忽略。 因此,我们给出以下审查结论: 问题列表:
由于PR较大,我们主要关注了回收站功能的实现,其他细节(如样式)可能需要在测试中进一步验证。 以上。 代码审查总结主要变更
发现的问题及改进建议1. 后端服务问题问题 // 不一致的时间格式
curStatus: {status: RECORD_STATUS.REMOVED, date: Date.now()} // 时间戳
curStatus: {status: RECORD_STATUS.EDITING, date: new Date()} // Date对象建议 // 统一修改为
curStatus: {status: RECORD_STATUS.REMOVED, date: new Date()}2. 权限控制问题问题 role: [
SurveyPermissions.SurveyManage,
// ...其他权限,
SurveyPermissions.RecyclebinManage // 硬编码
]建议 const requiredPermissions = [
SurveyPermissions.SurveyManage,
SurveyPermissions.DataManage,
SurveyPermissions.CollaboratorManage
];
if (userHasRecyclePermission) {
requiredPermissions.push(SurveyPermissions.RecyclebinManage);
}3. 前端状态管理问题问题 // 混合逻辑
const tempListFilter = [...originalListFilter];
tempListFilter.push({
comparator: payload.recycle ? '$eq' : '$ne',
condition: [{ field: 'curStatus.status', comparator: '$eq', value: 'removed' }]
});建议 // 独立回收站查询方法
async function getRecycleList(params) {
const filter = {
"curStatus.status": { $eq: RECORD_STATUS.REMOVED }
};
return fetchSurveyList({ ...params, filter });
}4. 安全问题问题 await this.surveyMetaService.removeSurveyMeta({
operatorId: req.user._id.toString() // 暴露用户ID
});建议 operatorId: req.session.userId // 从会话获取5. 测试覆盖不足问题
建议 it('should forbid restoring permanently deleted survey', async () => {
// 模拟物理删除后尝试恢复
jest.spyOn(service, 'restoreSurveyMeta').mockRejectedValue(new Error());
await expect(controller.restoreSurvey(/*...*/)).rejects.toThrow();
});6. 前端用户体验问题 <el-table-column prop="deleteAt" /> // 实际使用 updatedAt建议 // 服务端修改
async removeSurveyMeta() {
$set: {
deletedAt: new Date(), // 新增字段
updatedAt: new Date()
}
}优化总结
建议优先处理高优先级问题,尤其是安全相关和核心功能稳定性问题。 |
改动原因:新增回收站功能
改动内容:前端实现回收站页面,并将删除问卷操作转化为放入回收站,再由回收站的软删除功能进行永久删除。同时支持回收站问卷的恢复功能。
改动验证:本地全流程测试和配套单测。
方案设计:https://cww4jizadwz.feishu.cn/docx/YMQLdEdxyoPUXlxvuPUcKBJVnQe?from=from_copylink