ClearSeoTdk.php
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
namespace App\Console\Commands\Tdk;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* 清除项目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' => '',
],
'gl_ai_blog' => [
'seo_title' => '',
'seo_keyword' => '',
'seo_description' => '',
],
'gl_ai_blog_author' => [
'seo_title' => '',
'seo_keyword' => '',
'seo_description' => '',
],
'gl_custom_module_category' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_description' => '',
],
'gl_custom_module_content' => [
'seo_title' => '',
'seo_keywords' => '',
'seo_description' => '',
],
];
/**
* @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;
}
}