| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Module\GameItems\Jobs;
- use App\Module\Test\Models\Test;
- use UCore\Queue\QueueJob;
- /**
- * 测试队列任务类
- *
- * 用于测试和调试目的的队列任务类。
- * 此类主要在开发阶段使用,用于测试队列系统的功能。
- * 不建议在生产环境中使用此队列任务类。
- */
- class TestJob extends QueueJob
- {
- /**
- * 测试模型实例
- *
- * @var Test
- */
- protected Test $test;
- /**
- * 创建任务实例
- *
- * @param Test $test
- */
- public function __construct(Test $test)
- {
- $this->test = $test;
- parent::__construct(['test_id' => $test->id]);
- }
- /**
- * 执行任务
- *
- * @return bool
- */
- public function run(): bool
- {
- // 任务处理逻辑
- return true;
- }
- /**
- * 获取任务数据
- *
- * @return array
- */
- public function payload()
- {
- return [
- 'test_id' => $this->test->id,
- 'test_data' => $this->test->toArray()
- ];
- }
- }
|