AiBlogKeywordLogic.php
2.4 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
<?php
/**
* @remark :
* @name :AiBlogKeywordLogic.php
* @author :lyh
* @method :post
* @time :2025/11/4 14:37
*/
namespace App\Http\Logic\Bside\Ai;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiBlogKeyword;
use App\Models\Project\ProjectKeyword;
use App\Models\WebSetting\WebSetting;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class AiBlogKeywordLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new AiBlogKeyword();
}
/**
* @remark :获取当前详情
* @name :getKeywordInfo
* @author :lyh
* @method :post
* @time :2025/11/4 14:39
*/
public function getKeywordInfo()
{
$data = $this->model->read(['project_id'=>$this->user['project_id']]);
if($data === false){
//核心关键词+网站关键词+白帽关键词
$main_keywords = ProjectKeyword::where('project_id', $this->user['project_id'])->value('main_keyword');
$main_keywords = explode("\r\n", $main_keywords);
$seo_keywords = ProjectKeyword::where('project_id', $this->user['project_id'])->value('seo_keywords');
$seo_keywords = explode("\r\n", $seo_keywords);
$site_keywords = WebSetting::where('project_id', $this->user['project_id'])->value('keyword');
$site_keywords = explode(",", $site_keywords);
$keywords = array_filter(array_merge($main_keywords, $site_keywords, $seo_keywords));
$keywords = array_map('trim', $keywords);
$keywords_string = implode("\n", $keywords);
$data = [
'project_id'=>$this->user['project_id'],
'keywords'=>$keywords_string
];
}
return $this->success($data);
}
/**
* @remark :
* @name :saveKeyword
* @author :lyh
* @method :post
* @time :2025/11/4 14:52
*/
public function saveKeyword()
{
$data = $this->model->read(['project_id'=>$this->user['project_id']]);
if($data !== false){
$id = $data['id'];
$this->model->edit($this->param,['id'=>$id]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
}
return $this->success(['id'=>$id]);
}
}