作者 赵彬吉

update

  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Helper\Common;
  7 +use App\Helper\Gpt;
  8 +use App\Helper\Translate;
  9 +use App\Http\Logic\Aside\Project\ProjectLogic;
  10 +use App\Models\Ai\AiCommand;
  11 +use App\Models\Mail\Mail;
  12 +use App\Models\Project\DeployOptimize;
  13 +use App\Models\Project\ProjectUpdateTdk;
  14 +use App\Models\User\User;
  15 +use App\Services\ProjectServer;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Support\Facades\Cache;
  18 +use Illuminate\Support\Facades\DB;
  19 +use Illuminate\Support\Facades\Redis;
  20 +
  21 +/**
  22 + * 清除项目sdk
  23 + * Class InitProject
  24 + * @package App\Console\Commands
  25 + * @author zbj
  26 + * @date 2023/10/8
  27 + */
  28 +class ClearSeoTdk extends Command
  29 +{
  30 + /**
  31 + * The name and signature of the console command.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $signature = 'clear_seo_tdk {project_id}';
  36 +
  37 + /**
  38 + * The console command description.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $description = '清除项目sdk';
  43 +
  44 + /**
  45 + * Create a new command instance.
  46 + *
  47 + * @return void
  48 + */
  49 + public function __construct()
  50 + {
  51 + parent::__construct();
  52 + }
  53 +
  54 + /**
  55 + * '表' => [
  56 + * '指令key' => '表字段'
  57 + * ]
  58 + * @return array
  59 + * @author zbj
  60 + * @date 2023/11/3
  61 + */
  62 + protected $maps = [
  63 + 'gl_web_custom_template' => [
  64 + 'title' => '',
  65 + 'keywords' => '',
  66 + 'description' => '',
  67 + ],
  68 + 'gl_product' => [
  69 + 'seo_mate' => null
  70 + ],
  71 + 'gl_product_category' => [
  72 + 'seo_title' => '',
  73 + 'seo_keywords' => '',
  74 + 'seo_des' => '',
  75 + ],
  76 + 'gl_blog' => [
  77 + 'seo_title' => '',
  78 + 'seo_keywords' => '',
  79 + 'seo_description' => '',
  80 + ],
  81 + 'gl_blog_category' => [
  82 + 'seo_title' => '',
  83 + 'seo_keywords' => '',
  84 + 'seo_des' => '',
  85 + ],
  86 + 'gl_news' => [
  87 + 'seo_title' => '',
  88 + 'seo_keywords' => '',
  89 + 'seo_description' => '',
  90 + ],
  91 + 'gl_news_category' => [
  92 + 'seo_title' => '',
  93 + 'seo_keywords' => '',
  94 + 'seo_des' => '',
  95 + ],
  96 + 'gl_product_keyword' => [
  97 + 'seo_title' => '',
  98 + 'seo_keywords' => '',
  99 + 'seo_description' => '',
  100 + 'keyword_title' => '',
  101 + 'keyword_content' => '',
  102 + ]
  103 + ];
  104 +
  105 + /**
  106 + * @return bool
  107 + */
  108 + public function handle()
  109 + {
  110 + $project_id = $this->argument('project_id');
  111 + $project = ProjectServer::useProject($project_id);
  112 + if(!$project){
  113 + echo '项目不存在或数据库未配置' . PHP_EOL;
  114 + exit;
  115 + }
  116 + if ($this->confirm('你确认清空['. $project['title'] .']的sdk?')) {
  117 + foreach ($this->maps as $table => $data) {
  118 + echo date('Y-m-d H:i:s') . '清空SDK--' . $table . PHP_EOL;
  119 + DB::connection('custom_mysql')->table($table)->update($data);
  120 + }
  121 + }
  122 +
  123 + echo date('Y-m-d H:i:s') . '清空完成' . PHP_EOL;
  124 + }
  125 +}
@@ -50,6 +50,8 @@ class AiCommandLogic extends BaseLogic @@ -50,6 +50,8 @@ class AiCommandLogic extends BaseLogic
50 $main_keywords = array_slice($main_keywords, 0, 8); 50 $main_keywords = array_slice($main_keywords, 0, 8);
51 $main_keywords = implode(",", $main_keywords); 51 $main_keywords = implode(",", $main_keywords);
52 $prompt = str_replace('{core keywords 8}', $main_keywords, $prompt); 52 $prompt = str_replace('{core keywords 8}', $main_keywords, $prompt);
  53 + }else{
  54 + $prompt = '';
53 } 55 }
54 } 56 }
55 57