Commit dce600fd authored by hangjun83's avatar hangjun83

openapi

parent d0be1061
<?php
namespace App\Console\Commands;
use App\Jobs\BjsJob;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
class BjsJobCommand extends Command
{
use ConfirmableTrait;
/**
* 命令行的名称及用法。
*
* @var string
*/
protected $signature = 'bjs:job
{--action_type= : 任务操作类型}
{--params= : 任务参数}';
/**
* 命令行的概述。
*
* @var string
*/
protected $description = 'bjs更新cas数据';
/**
* 创建新的命令实例。
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* 运行命令。
* @throws \Exception
*/
public function handle()
{
if (! $this->confirmToProceed()) {
return 1;
}
if($this->hasArgument('help')){
$this->help();
}else{
$action_type = $this->option('action_type');
$params = $this->option('params');
if(empty($action_type)){
$this->error('缺少命令参数,请输入具体的参数命令.如需帮助请输入 --help');
exit;
}
$productUpdateJob = (new BjsJob($action_type,$params))->delay(100)->onQueue('slow');
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob);
}
}
public function help()
{
$helpStr = "参数帮助说明";
$this->comment($this->setHelp($helpStr)->getProcessedHelp());
$this->line("action_type: 具体动作参数\n\n initProductToExcel => 初始化批量商品 \n batchUpdateProduct => 批量更新商品\n\nparams : 操作需要传入的参数.非必填项");
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Jobs;
use App\Services\BjsService;
class BjsJob extends Job
{
protected $actionType = null;
protected $params = null;
public function __construct($actionType,$params)
{
$this->actionType = $actionType;
$this->params = $params;
}
public function handle()
{
$service = app(BjsService::class);
switch($this->actionType){
case 'batchUpdateProduct' :
default:
$service->batchUpdateProducts($this->params);
break;
}
}
}
......@@ -48,6 +48,7 @@ class AppServiceProvider extends ServiceProvider
\App\Console\Commands\IntegleJobCommand::class,
\App\Console\Commands\WuxiLabJobCommand::class,
\App\Console\Commands\BideJobCommand::class,
\App\Console\Commands\BjsJobCommand::class,
\App\Console\Commands\KafkaConsumerCommand::class
]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment