正在显示
1 个修改的文件
包含
63 行增加
和
0 行删除
app/Console/Commands/WebsiteData.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Models\File\DataFile; | ||
| 6 | +use Illuminate\Console\Command; | ||
| 7 | + | ||
| 8 | +class WebsiteData extends Command | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * The name and signature of the console command. | ||
| 12 | + * | ||
| 13 | + * @var string | ||
| 14 | + */ | ||
| 15 | + protected $signature = 'website_data'; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * The console command description. | ||
| 19 | + * | ||
| 20 | + * @var string | ||
| 21 | + */ | ||
| 22 | + protected $description = '向AICC推送数据'; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * Create a new command instance. | ||
| 26 | + * | ||
| 27 | + * @return void | ||
| 28 | + */ | ||
| 29 | + public function __construct() | ||
| 30 | + { | ||
| 31 | + parent::__construct(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Execute the console command. | ||
| 36 | + * | ||
| 37 | + * @return int | ||
| 38 | + */ | ||
| 39 | + public function handle() | ||
| 40 | + { | ||
| 41 | + $DataFile = new DataFile(); | ||
| 42 | + $data = $DataFile->allData(); | ||
| 43 | + # 详细数据 | ||
| 44 | + $items = $data['items']; | ||
| 45 | + # 总分页 | ||
| 46 | + $totalPage = $data['totalPage']; | ||
| 47 | + $this->post_data($items); | ||
| 48 | + if ($totalPage > 1) { | ||
| 49 | + for ($page = 2; $page <= $totalPage; $page++) { | ||
| 50 | + $da = $DataFile->allData($page); | ||
| 51 | + $this->post_data($da['items']); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + $this->info('项目文件数据推送完成!'); | ||
| 55 | + return 0; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public function post_data($data) | ||
| 59 | + { | ||
| 60 | + return http_post("http://aicc-local.com/api/save_file_data", json_encode(compact('data'))); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | +} |
-
请 注册 或 登录 后发表评论