2021-08-01 19:57:41 +08:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-09-11 12:41:28 +08:00
|
|
|
/**
|
|
|
|
* This is my open source code, please do not use it for commercial applications.
|
|
|
|
* For the full copyright and license information,
|
|
|
|
* please view the LICENSE file that was distributed with this source code
|
|
|
|
*
|
|
|
|
* @author Yuandong<837215079@qq.com>
|
|
|
|
* @link https://github.com/gzydong/hyperf-chat
|
|
|
|
*/
|
|
|
|
|
2021-08-01 19:57:41 +08:00
|
|
|
namespace App\Command;
|
|
|
|
|
2021-09-12 16:23:43 +08:00
|
|
|
use App\Service\RobotService;
|
2021-08-01 19:57:41 +08:00
|
|
|
use Hyperf\Command\Command as HyperfCommand;
|
|
|
|
use Hyperf\Command\Annotation\Command;
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Command
|
|
|
|
*/
|
|
|
|
class InstallCommand extends HyperfCommand
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ContainerInterface
|
|
|
|
*/
|
|
|
|
protected $container;
|
|
|
|
|
|
|
|
public function __construct(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
|
|
|
|
parent::__construct('system:install');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function configure()
|
|
|
|
{
|
|
|
|
parent::configure();
|
|
|
|
$this->setDescription('LumenIM 初始化数据表及生成测试数据!');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->line('LumenIM 正在创建数据库,请耐心等待!', 'info');
|
2021-09-12 16:23:43 +08:00
|
|
|
|
|
|
|
|
2021-08-01 19:57:41 +08:00
|
|
|
$this->call('migrate');
|
|
|
|
|
2021-09-12 16:23:43 +08:00
|
|
|
di()->get(RobotService::class)->create([
|
|
|
|
'robot_name' => "登录助手",
|
|
|
|
'describe' => "异地登录助手",
|
|
|
|
'logo' => '',
|
|
|
|
'is_talk' => 0,
|
|
|
|
'type' => 1,
|
|
|
|
]);
|
|
|
|
|
2021-08-06 23:57:49 +08:00
|
|
|
if ($this->confirm('是否需要生成测试数据?')) {
|
2021-08-01 19:57:41 +08:00
|
|
|
$this->call('db:seed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|