From a5b1fec6b1ed0d5f61cf0fb525f5103b4e4e6e37 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 13 Dec 2021 12:00:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Project.php | 2 +- app/Models/ProjectTask.php | 19 +++++++++----- app/Models/WebSocketDialog.php | 8 +++--- .../pages/manage/components/DialogWrapper.vue | 1 + .../assets/js/pages/manage/messenger.vue | 8 +++--- resources/assets/js/store/actions.js | 26 +++++++++++++++++++ .../assets/sass/pages/page-messenger.scss | 12 ++++++--- 7 files changed, 57 insertions(+), 19 deletions(-) diff --git a/app/Models/Project.php b/app/Models/Project.php index 43b810d5..9e27527c 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -379,7 +379,7 @@ class Project extends AbstractModel } $project = $builder->first(); if (empty($project)) { - throw new ApiException('项目不存在或不在成员列表内'); + throw new ApiException('项目不存在或不在成员列表内', [ 'project_id' => $project_id ], -4001); } return $project; } diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 681bb06e..02910ae6 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -7,6 +7,7 @@ use App\Module\Base; use App\Tasks\PushTask; use Arr; use Carbon\Carbon; +use Exception; use Hhxsv5\LaravelS\Swoole\Task\Task; use Illuminate\Database\Eloquent\SoftDeletes; use Request; @@ -753,16 +754,20 @@ class ProjectTask extends AbstractModel } $task = $builder->first(); if (empty($task)) { - throw new ApiException('任务不存在'); + throw new ApiException('任务不存在', [ 'task_id' => $task_id ], -4002); } // - if (ProjectTaskUser::whereUserid(User::userid())->whereTaskPid($task->id)->exists()) { - $project = Project::find($task->project_id); - if (empty($project)) { - throw new ApiException('项目不存在或已被删除'); - } - } else { + try { $project = Project::userProject($task->project_id, $ignoreArchived); + } catch (Exception $e) { + if (ProjectTaskUser::whereUserid(User::userid())->whereTaskPid($task->id)->exists()) { + $project = Project::find($task->project_id); + if (empty($project)) { + throw new ApiException('项目不存在或已被删除', [ 'task_id' => $task_id ], -4002); + } + } else { + throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002); + } } // return $task; diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 713bbd9a..cf982425 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -65,14 +65,14 @@ class WebSocketDialog extends AbstractModel /** * 获取对话(同时检验对话身份) - * @param $id + * @param $dialog_id * @return self */ - public static function checkDialog($id) + public static function checkDialog($dialog_id) { - $dialog = WebSocketDialog::whereId($id)->first(); + $dialog = WebSocketDialog::find($dialog_id); if (empty($dialog)) { - throw new ApiException('对话不存在或已被删除'); + throw new ApiException('对话不存在或已被删除', ['dialog_id' => $dialog_id], -4003); } // $userid = User::userid(); diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 606d0ccb..14484d70 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -1,5 +1,6 @@