优化任务项目归档

This commit is contained in:
kuaifan
2021-12-13 12:38:32 +08:00
parent a5b1fec6b1
commit cde6530832
4 changed files with 29 additions and 14 deletions

View File

@@ -744,18 +744,18 @@ class ProjectTask extends AbstractModel
* @param int $task_id
* @param array $with
* @param bool $ignoreArchived 排除已归档
* @param null $project
* @return self
*/
public static function userTask($task_id, $with = [], $ignoreArchived = true, &$project = null)
{
$builder = self::with($with)->whereId(intval($task_id));
if ($ignoreArchived) {
$builder->whereNull('archived_at');
}
$task = $builder->first();
$task = self::with($with)->whereId(intval($task_id))->first();
if (empty($task)) {
throw new ApiException('任务不存在', [ 'task_id' => $task_id ], -4002);
}
if ($ignoreArchived && $task->archived_at != null) {
throw new ApiException('任务已归档', [ 'task_id' => $task_id ], -4002);
}
//
try {
$project = Project::userProject($task->project_id, $ignoreArchived);