ProjectReset.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace App\Console\Commands\Update;
use App\Models\Com\UpdateLog;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ProjectReset extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'project_reset {project_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '项目采集重置';
public function handle()
{
$project_id = $this->argument('project_id');
$project = ProjectServer::useProject($project_id);
if ($project) {
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
} catch (\Exception $e) {
echo $project_id . ',重置失败' . PHP_EOL;
}
}
//关闭数据库
DB::disconnect('custom_mysql');
UpdateLog::where('project_id', $project_id)->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update(['status' => 0, 'collect_status' => 0]);
echo $project_id . ',重置成功' . PHP_EOL;
}
}