ReceiveVideosJob.php 907 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Jobs\Inner;
  3. use App\Model\VideoModel;
  4. use App\Repositories\VideoRepository;
  5. use Hyperf\AsyncQueue\Job;
  6. class ReceiveVideosJob extends Job
  7. {
  8. /**
  9. * @var null|VideoRepository
  10. */
  11. private $repo = null;
  12. /**
  13. * 参数
  14. * @var array|mixed
  15. */
  16. protected $params = [];
  17. public function __construct($params = [])
  18. {
  19. $this->params = $params;
  20. }
  21. public function handle()
  22. {
  23. if (!empty($this->params)) {
  24. foreach ($this->params as $item) {
  25. $result = $this->getRepo()->createOneFromMediaCenter($item);
  26. }
  27. }
  28. }
  29. /**
  30. * 获取仓库.
  31. * @return VideoRepository|mixed
  32. */
  33. private function getRepo()
  34. {
  35. if (!$this->repo instanceof VideoRepository) {
  36. $this->repo = make(VideoRepository::class);
  37. }
  38. return $this->repo;
  39. }
  40. }