upload preivew + es command

This commit is contained in:
xiaomlove
2022-04-01 23:13:42 +08:00
parent 5f6b3ceb53
commit 4172f7c07c
49 changed files with 347 additions and 126 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Repositories\SearchRepository;
use Illuminate\Console\Command;
class EsCreateIndex extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'es:create_index';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create index in Elasticsearch';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$rep = new SearchRepository();
$result = $rep->createIndex();
$log = sprintf("[%s], %s, result: \n%s", nexus()->getRequestId(), __METHOD__, var_export($result, true));
$this->info($log);
do_log($log);
return 0;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Repositories\SearchRepository;
use Illuminate\Console\Command;
class EsDeleteIndex extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'es:delete_index';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete index in Elasticsearch';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$rep = new SearchRepository();
$result = $rep->deleteIndex();
$log = sprintf("[%s], %s, result: \n%s", nexus()->getRequestId(), __METHOD__, var_export($result, true));
$this->info($log);
do_log($log);
return 0;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Console\Commands;
use App\Repositories\SearchRepository;
use Illuminate\Console\Command;
class EsImport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'es:import {--torrent_id=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import torrent to Elasticsearch, options: --torrent_id';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$rep = new SearchRepository();
$torrentId = $this->option('torrent_id');
$this->info("torrent_id: $torrentId");
$result = $rep->import($torrentId);
$log = sprintf("[%s], %s, result: \n%s", nexus()->getRequestId(), __METHOD__, var_export($result, true));
$this->info($log);
do_log($log);
return 0;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Repositories\SearchRepository;
use Illuminate\Console\Command;
class EsInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'es:info';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show Elasticsearch info';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$rep = new SearchRepository();
$result = $rep->getEsInfo();
$log = sprintf("[%s], %s, result: \n%s", nexus()->getRequestId(), __METHOD__, var_export($result, true));
$this->info($log);
do_log($log);
return 0;
}
}