AiDomainTask.php 1.5 KB
<?php
/**
 * @remark :
 * @name   :AiDomainTask.php
 * @author :lyh
 * @method :post
 * @time   :2025/6/19 10:53
 */

namespace App\Console\Commands\Ai;

use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;

/**
 * @remark :拉取项目Ai域名
 * @name   :AiDomainTask
 * @author :lyh
 * @method :post
 * @time   :2025/6/19 10:54
 */
class AiDomainTask extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'ai_domain';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '获取对应域名的ai复制站域名';

    public $url = 'https://www.cmer.site/api/globalso_site';
    public function handle(){
        $data = [];
        $pageSize = 100;
        $page = 1;
        $domainInfoModel = new DomainInfo();
        $res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
        if($res['status'] != 200){
            echo date('Y-m-d H:i:s').'请求失败,未拉取到数据';
            return false;
        }
        $data = $res['data']['data'];
        while($page <= $res['data']['last_page']){
            $res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
            if($res['status'] != 200){
                echo date('Y-m-d H:i:s').'第'.$page.'请求失败,未拉取到数据';
                return false;
            }
            $data = array_values(array_merge($data,$res['data']['data']));
            $page++;
        }
        dd($data);
    }
}