优化任务项目归档

This commit is contained in:
kuaifan
2021-12-13 12:43:53 +08:00
parent a5b1fec6b1
commit cde6530832
4 changed files with 29 additions and 14 deletions
+5 -6
View File
@@ -290,7 +290,7 @@ class Project extends AbstractModel
$this->addLog("项目归档");
$this->pushMsg('archived');
ProjectTask::whereProjectId($this->id)->whereArchivedAt(null)->update([
'archived_at' => Carbon::now(),
'archived_at' => $archived_at,
'archived_follow' => 1
]);
}
@@ -373,14 +373,13 @@ class Project extends AbstractModel
*/
public static function userProject($project_id, $ignoreArchived = true)
{
$builder = self::select(self::projectSelect)->authData()->where('projects.id', intval($project_id));
if ($ignoreArchived) {
$builder->whereNull('projects.archived_at');
}
$project = $builder->first();
$project = self::select(self::projectSelect)->authData()->where('projects.id', intval($project_id))->first();
if (empty($project)) {
throw new ApiException('项目不存在或不在成员列表内', [ 'project_id' => $project_id ], -4001);
}
if ($ignoreArchived && $project->archived_at != null) {
throw new ApiException('项目已归档', [ 'project_id' => $project_id ], -4001);
}
return $project;
}
}