作者 赵彬吉

update

<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\Gpt;
use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiCommand;
use App\Models\Mail\Mail;
use App\Models\Project\DeployOptimize;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\User\User;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* 清除项目sdk
* Class InitProject
* @package App\Console\Commands
* @author zbj
* @date 2023/10/8
*/
class ClearSeoTdk extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'clear_seo_tdk {project_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '清除项目sdk';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* '表' => [
* '指令key' => '表字段'
* ]
* @return array
* @author zbj
* @date 2023/11/3
*/
protected $maps = [
'gl_web_custom_template' => [
'title' => '',
'keywords' => '',
'description' => '',
],
'gl_product' => [
'seo_mate' => null
],
'gl_product_category' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_des' => '',
],
'gl_blog' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_description' => '',
],
'gl_blog_category' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_des' => '',
],
'gl_news' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_description' => '',
],
'gl_news_category' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_des' => '',
],
'gl_product_keyword' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_description' => '',
'keyword_title' => '',
'keyword_content' => '',
]
];
/**
* @return bool
*/
public function handle()
{
$project_id = $this->argument('project_id');
$project = ProjectServer::useProject($project_id);
if(!$project){
echo '项目不存在或数据库未配置' . PHP_EOL;
exit;
}
if ($this->confirm('你确认清空['. $project['title'] .']的sdk?')) {
foreach ($this->maps as $table => $data) {
echo date('Y-m-d H:i:s') . '清空SDK--' . $table . PHP_EOL;
DB::connection('custom_mysql')->table($table)->update($data);
}
}
echo date('Y-m-d H:i:s') . '清空完成' . PHP_EOL;
}
}
... ...
... ... @@ -50,6 +50,8 @@ class AiCommandLogic extends BaseLogic
$main_keywords = array_slice($main_keywords, 0, 8);
$main_keywords = implode(",", $main_keywords);
$prompt = str_replace('{core keywords 8}', $main_keywords, $prompt);
}else{
$prompt = '';
}
}
... ...