123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- * Queue.php UTF-8
- *
- * @date : 2021/5/6 15:08
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HUOSDK-IDENTITY 1.0
- */
- namespace huoIdentify\lib\queue\controller;
- use huoIdentify\controller\Common;
- use huolib\status\CommonStatus;
- class Queue extends Common {
- protected $param = [];
- protected $job_class = '';
- protected $job_name = '';
- public function __construct() {
- $this->param['ts'] = time();
- }
- /**
- * 返回数据
- *
- * @param int $code
- * @param array $data
- *
- * @return array
- */
- protected function retSucMsg($code = CommonStatus::NO_ERROR, $data = []) {
- /* 数据录入LOG */
- $this->param['queue'] = '1';
- return $this->huoSuccess($code, CommonStatus::getMsg($code), $data);
- }
- /**
- * 返回数据
- *
- * @param $code
- *
- * @return array|mixed
- */
- protected function retErrMsg($code = CommonStatus::PUSH_QUEUE_ERROR) {
- /* 数据录入LOG */
- $this->param['queue'] = '0';
- return $this->huoError($code, CommonStatus::getMsg($code));
- }
- /**
- * 入队列
- *
- * @return array
- */
- public function pushQueue() {
- if (class_exists('think\\Queue')) {
- $_is_pushed = \think\Queue::push($this->job_class, $this->param, $this->job_name);
- if ($_is_pushed === false) {
- return $this->retErrMsg();
- }
- }
- return $this->retSucMsg();
- }
- /**
- * @return array
- */
- public function getParam() {
- return $this->param;
- }
- /**
- * @param array $param
- */
- public function setParam($param) {
- $this->param = array_merge($this->param, $param);
- }
- /**
- * @return string
- */
- public function getJobClass() {
- return $this->job_class;
- }
- /**
- * @param string $job_class
- */
- public function setJobClass($job_class) {
- $this->job_class = $job_class;
- }
- /**
- * @return string
- */
- public function getJobName() {
- return $this->job_name;
- }
- /**
- * @param string $job_name
- */
- public function setJobName($job_name) {
- $this->job_name = $job_name;
- }
- }
|