优化任务、列表数量限制

This commit is contained in:
kuaifan 2022-01-06 19:12:49 +08:00
parent 77a9eca634
commit f919a34166
2 changed files with 24 additions and 1 deletions

View File

@ -758,6 +758,10 @@ class ProjectController extends AbstractController
if (empty($name)) {
return Base::retError('列表名称不能为空');
}
if (ProjectColumn::whereProjectId($project->id)->count() > 50) {
return Base::retError('项目列表最多不能超过50个');
}
//
$column = ProjectColumn::createInstance([
'project_id' => $project->id,
'name' => $name,

View File

@ -344,6 +344,25 @@ class ProjectTask extends AbstractModel
$p_color = $data['p_color'];
$top = intval($data['top']);
//
if (ProjectTask::whereProjectId($project_id)
->whereNull('project_tasks.complete_at')
->whereNull('project_tasks.archived_at')
->count() > 2000) {
throw new ApiException('项目内未完成任务最多不能超过2000个');
}
if (ProjectTask::whereColumnId($column_id)
->whereNull('project_tasks.complete_at')
->whereNull('project_tasks.archived_at')
->count() > 500) {
throw new ApiException('单个列表未完成任务最多不能超过500个');
}
if ($parent_id > 0 && ProjectTask::whereParentId($parent_id)
->whereNull('project_tasks.complete_at')
->whereNull('project_tasks.archived_at')
->count() > 50) {
throw new ApiException('每个任务的子任务最多不能超过50个');
}
//
$retPre = $parent_id ? '子任务' : '任务';
$task = self::createInstance([
'parent_id' => $parent_id,
@ -383,7 +402,7 @@ class ProjectTask extends AbstractModel
->whereNull('project_tasks.complete_at')
->whereNull('project_tasks.archived_at')
->count() > 500) {
throw new ApiException(User::userid2nickname($uid) . '负责或参与的任务超过500个未完成');
throw new ApiException(User::userid2nickname($uid) . '负责或参与的未完成任务最多不能超过500个');
}
$tmpArray[] = $uid;
}