ApiNoChecking.php
1.1 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
<?php
namespace App\Console\Commands\Domain;
use App\Models\Project\DeployOptimize;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
class ApiNoChecking extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'api_no_checking';
/**
* The console command description.
*
* @var string
*/
protected $description = '每日检查项目api编号是否正在监控';
public function handle()
{
$api_url = 'http://api.quanqiusou.cn/api/index/weblist?key=289c1fc81c89d79c04ed4fd72822948e';
$data = Http::timeout(60)->get($api_url)->json();
if (is_array($data) && $data) {
$api_no_list = array_keys($data);
if ($api_no_list) {
DeployOptimize::where('api_no', '>', 0)->where('api_no_checking', '>', 0)->update(['api_no_checking' => 0]);
DeployOptimize::whereIn('api_no', $api_no_list)->update(['api_no_checking' => 1]);
}
}
return true;
}
}