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 727d7e1 commit 0737a9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions app/Http/Controllers/Api/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,6 @@ public function task__lists()
$query->where('project_users.owner', 1);
$query->where('project_users.userid', $userid);
});
$builder->leftJoin('project_task_users as project_sub_task_users', function ($query) use($userid) {
$query->on('project_sub_task_users.task_pid', '=', 'project_tasks.parent_id');
$query->where('project_sub_task_users.userid', $userid);
});
$builder->leftJoin('project_task_visibility_users', function ($query) use($userid) {
$query->on('project_task_visibility_users.task_id', '=', 'project_tasks.id');
$query->where('project_task_visibility_users.userid', $userid);
Expand All @@ -1071,7 +1067,6 @@ public function task__lists()
$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_users.userid", $userid);
});
// 优化子查询汇总
$builder->leftJoinSub(function ($query) {
Expand Down
4 changes: 2 additions & 2 deletions app/Observers/ProjectTaskObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function userids(ProjectTask $projectTask, array|string $dataType
}
$array = [];
if (in_array('task', $dataType)) {
$array = array_merge($array, ProjectTaskUser::whereTaskId($projectTask->id)->pluck('userid')->toArray());
$array = array_merge($array, ProjectTaskUser::whereTaskId($projectTask->id)->orWhere('task_pid' ,$projectTask->id)->pluck('userid')->toArray());
}
if (in_array('visibility', $dataType)) {
$array = array_merge($array, ProjectTaskVisibilityUser::whereTaskId($projectTask->id)->pluck('userid')->toArray());
Expand All @@ -113,7 +113,7 @@ public static function visibilityUpdate(ProjectTask $projectTask)
break;
case 2:
case 3:
$dataType = $projectTask->visibility == 2 ? ['task'] : ['task', 'visibility'];
$dataType = $projectTask->visibility == 2 ? ['task'] : ['visibility'];
$forgetUserids = self::userids($projectTask, $dataType);
$projectOwnerUserIds = self::userids($projectTask, 'projectOwnerUser');
$recordUserids = array_diff($projectUserids, $forgetUserids, $projectOwnerUserIds);
Expand Down

0 comments on commit 0737a9f

Please sign in to comment.