2026-02-15 19:41:56 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\command;
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
use support\think\Db;
|
|
|
|
|
use isszz\hashids\facade\Hashids;
|
|
|
|
|
use function GuzzleHttp\json_encode;
|
|
|
|
|
|
|
|
|
|
class User extends Command
|
|
|
|
|
{
|
|
|
|
|
protected static $defaultName = 'User';
|
|
|
|
|
protected static $defaultDescription = '用户';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function configure()
|
|
|
|
|
{
|
|
|
|
|
$this->addOption('user_id','u', InputArgument::OPTIONAL, 'user_id');
|
|
|
|
|
$this->addOption('action','a', InputArgument::OPTIONAL, '操作类型');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param InputInterface $input
|
|
|
|
|
* @param OutputInterface $output
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
|
{
|
|
|
|
|
$action = $input->getOption('action','login');
|
|
|
|
|
if($action == 'login'){
|
|
|
|
|
$IM = new \support\OpenImSdk\Client([
|
|
|
|
|
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
|
|
|
|
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
|
|
|
|
]);
|
|
|
|
|
$user_id = $input->getOption('user_id');
|
|
|
|
|
if(!$user_id){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$user = \support\Jwt::direct($user_id);
|
2026-03-01 21:05:19 +08:00
|
|
|
$imToken = $IM->auth->getUserToken($user['userID'],2);
|
2026-02-15 19:41:56 +08:00
|
|
|
cp('userID:' . $user['id']);
|
|
|
|
|
cp('nickname:' . $user['nickname']);
|
|
|
|
|
cp('token:' . $user['token']);
|
|
|
|
|
cp('imToken:' . $imToken['token']);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
cp('action not exist');
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|