| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Jobs\Inner;
- use App\Model\VideoModel;
- use App\Repositories\VideoRepository;
- use Hyperf\AsyncQueue\Job;
- class ReceiveVideosJob extends Job
- {
- /**
- * @var null|VideoRepository
- */
- private $repo = null;
- /**
- * 参数
- * @var array|mixed
- */
- protected $params = [];
- public function __construct($params = [])
- {
- $this->params = $params;
- }
- public function handle()
- {
- if (!empty($this->params)) {
- foreach ($this->params as $item) {
- $result = $this->getRepo()->createOneFromMediaCenter($item);
- }
- }
- }
- /**
- * 获取仓库.
- * @return VideoRepository|mixed
- */
- private function getRepo()
- {
- if (!$this->repo instanceof VideoRepository) {
- $this->repo = make(VideoRepository::class);
- }
- return $this->repo;
- }
- }
|