Skip to content

Commit

Permalink
fix: 修复任务可见性 - 任务重覆获取, 子任务负责人看不到任务问题
Browse files Browse the repository at this point in the history
  • Loading branch information
weifashi committed Dec 23, 2024
1 parent 0737a9f commit ef273bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/Http/Controllers/Api/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,11 +1062,16 @@ public function task__lists()
$query->on('project_task_visibility_users.task_id', '=', 'project_tasks.id');
$query->where('project_task_visibility_users.userid', $userid);
});
$builder->leftJoin('project_task_visibility_users as project_sub_task_visibility_users', function ($query) use($userid) {
$query->on('project_sub_task_visibility_users.task_id', '=', 'project_tasks.parent_id');
$query->where('project_sub_task_visibility_users.userid', $userid);
});
$builder->where(function ($query) use ($userid) {
$query->where("project_tasks.visibility", 1);
$query->orWhere("project_users.userid", $userid);
$query->orWhere("project_task_users.userid", $userid);
$query->orWhere("project_task_visibility_users.userid", $userid);
$query->orWhere("project_sub_task_visibility_users.userid", $userid);
});
// 优化子查询汇总
$builder->leftJoinSub(function ($query) {
Expand Down
2 changes: 1 addition & 1 deletion app/Observers/ProjectTaskObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function visibilityUpdate(ProjectTask $projectTask)
break;
case 2:
case 3:
$dataType = $projectTask->visibility == 2 ? ['task'] : ['visibility'];
$dataType = $projectTask->visibility == 2 ? ['task'] : ['task', 'visibility'];
$forgetUserids = self::userids($projectTask, $dataType);
$projectOwnerUserIds = self::userids($projectTask, 'projectOwnerUser');
$recordUserids = array_diff($projectUserids, $forgetUserids, $projectOwnerUserIds);
Expand Down
3 changes: 3 additions & 0 deletions app/Observers/ProjectTaskUserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class ProjectTaskUserObserver
public function created(ProjectTaskUser $projectTaskUser)
{
Deleted::forget('projectTask', $projectTaskUser->task_id, $projectTaskUser->userid);
if ($projectTaskUser->task_pid) {
Deleted::forget('projectTask', $projectTaskUser->task_pid, $projectTaskUser->userid);
}
}

/**
Expand Down

0 comments on commit ef273bd

Please sign in to comment.