正在显示
2 个修改的文件
包含
29 行增加
和
71 行删除
app/Console/Commands/Test/Demo.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * @remark : | ||
| 4 | - * @name :Demo.php | ||
| 5 | - * @author :lyh | ||
| 6 | - * @method :post | ||
| 7 | - * @time :2025/2/20 9:19 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -namespace App\Console\Commands\Test; | ||
| 11 | - | ||
| 12 | -use Illuminate\Console\Command; | ||
| 13 | - | ||
| 14 | -class Demo extends Command | ||
| 15 | -{ | ||
| 16 | - /** | ||
| 17 | - * The name and signature of the console command. | ||
| 18 | - * | ||
| 19 | - * @var string | ||
| 20 | - */ | ||
| 21 | - protected $signature = 'demo'; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * The console command description. | ||
| 25 | - * | ||
| 26 | - * @var string | ||
| 27 | - */ | ||
| 28 | - protected $description = ''; | ||
| 29 | - | ||
| 30 | - public function handle(){ | ||
| 31 | - return $this->getExtendProjects(); | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - public function getExtendProjects($api_no = null) | ||
| 35 | - { | ||
| 36 | - $key = 'extend_projects_list'; | ||
| 37 | - $data = Cache::get($key); | ||
| 38 | - if (!$data) { | ||
| 39 | - $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php'; | ||
| 40 | - try { | ||
| 41 | - $data = HttpUtils::get($api_url, []); | ||
| 42 | - if ($data) { | ||
| 43 | - $data = Arr::s2a($data); | ||
| 44 | - Cache::put($key, $data, 4 * 3600); | ||
| 45 | - } | ||
| 46 | - } catch (\Exception | GuzzleException $e) { | ||
| 47 | - errorLog('复制站点项目获取失败', [], $e); | ||
| 48 | - return false; | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | - if ($api_no !== null) { | ||
| 52 | - $data = collect($data)->where('apino', $api_no)->first(); | ||
| 53 | - return $data ?: []; | ||
| 54 | - } | ||
| 55 | - echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL; | ||
| 56 | - return $data; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | -} |
| @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap; | @@ -23,7 +23,10 @@ use App\Models\RouteMap\RouteMap; | ||
| 23 | use App\Models\Template\BTemplate; | 23 | use App\Models\Template\BTemplate; |
| 24 | use App\Models\Template\Setting; | 24 | use App\Models\Template\Setting; |
| 25 | use App\Services\ProjectServer; | 25 | use App\Services\ProjectServer; |
| 26 | +use App\Utils\HttpUtils; | ||
| 27 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 26 | use Illuminate\Console\Command; | 28 | use Illuminate\Console\Command; |
| 29 | +use Illuminate\Support\Facades\Cache; | ||
| 27 | use Illuminate\Support\Facades\DB; | 30 | use Illuminate\Support\Facades\DB; |
| 28 | use Illuminate\Support\Facades\Schema; | 31 | use Illuminate\Support\Facades\Schema; |
| 29 | 32 | ||
| @@ -58,22 +61,36 @@ class UpdateRoute extends Command | @@ -58,22 +61,36 @@ class UpdateRoute extends Command | ||
| 58 | * @time :2023/11/20 15:13 | 61 | * @time :2023/11/20 15:13 |
| 59 | */ | 62 | */ |
| 60 | public function handle(){ | 63 | public function handle(){ |
| 61 | - $projectModel = new Project(); | ||
| 62 | - $list = $projectModel->list(['delete_status'=>['=',0],'id'=>1462]); | ||
| 63 | - foreach ($list as $v){ | ||
| 64 | - echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 65 | - ProjectServer::useProject($v['id']); | ||
| 66 | - $this->ceshi(); | ||
| 67 | - DB::disconnect('custom_mysql'); | ||
| 68 | - } | ||
| 69 | - echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 64 | + |
| 65 | + $data = $this->ceshi(); | ||
| 66 | + | ||
| 67 | + echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL; | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | - public function ceshi() | 70 | + |
| 71 | + public function ceshi($api_no = null) | ||
| 73 | { | 72 | { |
| 74 | - return true; | 73 | + $key = 'extend_projects_list'; |
| 74 | + $data = Cache::get($key); | ||
| 75 | + if (!$data) { | ||
| 76 | + $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php'; | ||
| 77 | + try { | ||
| 78 | + $data = HttpUtils::get($api_url, []); | ||
| 79 | + if ($data) { | ||
| 80 | + $data = Arr::s2a($data); | ||
| 81 | + Cache::put($key, $data, 4 * 3600); | ||
| 82 | + } | ||
| 83 | + } catch (\Exception | GuzzleException $e) { | ||
| 84 | + errorLog('复制站点项目获取失败', [], $e); | ||
| 85 | + return false; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + if ($api_no !== null) { | ||
| 89 | + $data = collect($data)->where('apino', $api_no)->first(); | ||
| 90 | + return $data ?: []; | ||
| 91 | + } | ||
| 92 | + return $data; | ||
| 75 | } | 93 | } |
| 76 | - | ||
| 77 | /** | 94 | /** |
| 78 | * @remark :更新产品 | 95 | * @remark :更新产品 |
| 79 | * @name :updateProduct | 96 | * @name :updateProduct |
-
请 注册 或 登录 后发表评论