项目增删通知

This commit is contained in:
Pang
2021-06-18 01:02:01 +08:00
parent c3fe7c1f7e
commit 41825ea4d4
6 changed files with 80 additions and 44 deletions
+26 -7
View File
@@ -4,6 +4,8 @@ namespace App\Models;
use App\Exceptions\ApiException;
use App\Module\Base;
use App\Tasks\PushTask;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
@@ -262,14 +264,12 @@ class Project extends AbstractModel
WebSocketDialog::whereId($this->dialog_id)->delete();
$columns = ProjectColumn::whereProjectId($this->id)->get();
foreach ($columns as $column) {
$column->deleteColumn();
}
if ($this->delete()) {
$this->addLog("删除项目");
return Base::retSuccess('删除成功', $this->toArray());
} else {
return Base::retError('删除失败', $this->toArray());
$column->deleteColumn(false);
}
$this->pushMsg('delete', $this->toArray());
$this->delete();
$this->addLog("删除项目");
return Base::retSuccess('删除成功', $this->toArray());
});
return Base::isSuccess($result);
}
@@ -293,6 +293,25 @@ class Project extends AbstractModel
return $log;
}
/**
* 推送消息
* @param string $action
* @param array $data
*/
public function pushMsg($action, $data)
{
$lists = [
'userid' => $this->relationUserids(),
'msg' => [
'type' => 'project',
'action' => $action,
'data' => $data,
]
];
$task = new PushTask($lists, false);
Task::deliver($task);
}
/**
* 根据用户获取项目信息(用于判断会员是否存在项目内)
* @param int $project_id