作者 lyh

gx

... ... @@ -41,18 +41,48 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
return $this->aggregate_keyword_affix();
//获取
$keywordPrefixModel = new KeywordPrefix();
$lists = $keywordPrefixModel->list(['project_id'=>0,'id'=>['<',29]]);
$whiteModel = new ProjectWhiteHatAffix();
foreach ($lists as $val) {
echo date('Y-m-d H:i:s') . '开始--项目的id:' . $val['id'] . PHP_EOL;
// $keywordPrefixModel = new KeywordPrefix();
// $lists = $keywordPrefixModel->list(['project_id'=>0,'id'=>['<',29]]);
// $whiteModel = new ProjectWhiteHatAffix();
// foreach ($lists as $val) {
// echo date('Y-m-d H:i:s') . '开始--项目的id:' . $val['id'] . PHP_EOL;
// $data = [
// 'project_id'=>0,
// 'name'=>$val['keyword'],
// 'type'=>$val['type'],
// ];
// $whiteModel->add($data);
// }
return true;
}
/**
* @remark :获取数据
* @name :aggregate_keyword_affix
* @author :lyh
* @method :post
* @time :2025/6/26 17:58
*/
public function aggregate_keyword_affix(){
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'extend_type'=>0,'type'=>['in',[2,4]]], 'id', ['id']);
$keywordAffixModel = new AggregateKeywordAffix();
foreach ($lists as $val){
$info = $keywordAffixModel->read(['project_id'=>$val['id']]);
$prefix = "How To find"."\n"."Why Choose"."\n"."China Top"."\n"."Best Way To Choose"."\n"."Methods To Choose";
$suffix = "Manufacturer"."\n"."Supplier"."\n"."Products"."\n"."Factory";
if($info === false){
echo '执行的项目id:'.$val['id'].PHP_EOL;
$data = [
'project_id'=>0,
'name'=>$val['keyword'],
'type'=>$val['type'],
'project_id'=>$val['id'],
'prefix'=>$prefix,
'suffix'=>$suffix,
];
$whiteModel->add($data);
$keywordAffixModel->addReturnId($data);
}
}
return true;
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Services;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\AggregateKeywordAffix;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
... ... @@ -140,6 +141,8 @@ class ProjectServer
self::initColumn();
//初始化search页面
// self::initSearchPage($project_id);
//聚合页关键词前后缀
self::initAggregateKeywordAffix($project_id);
DB::disconnect('custom_mysql');
return true;
}
... ... @@ -280,4 +283,30 @@ class ProjectServer
}
}
}
/**
* @remark :gl_aggregate_keyword_affix处理聚合页关键词前后缀
* @name :initAffix
* @author :lyh
* @method :post
* @time :2025/6/26 17:48
*/
public static function initAggregateKeywordAffix($project_id){
$time = date('Y-m-d H:i:s');
$prefix = "How To find"."\n"."Why Choose"."\n"."China Top"."\n"."Best Way To Choose"."\n"."Methods To Choose";
$suffix = "Manufacturer"."\n"."Supplier"."\n"."Products"."\n"."Factory";
$aggregateKeywordAffixModel = new AggregateKeywordAffix();
$info = DB::connection('custom_mysql')->table('gl_aggregate_keyword_affix')->first();
if(empty($info)){
$data = [
'project_id'=>$project_id,
'prefix'=>$prefix,
'suffix'=>$suffix,
'created_at' => $time,
'updated_at' => $time
];
DB::connection('custom_mysql')->table('gl_aggregate_keyword_affix')->insert($data);
}
return true;
}
}
... ...