AggregateKeywordAffixLogic.php
1.6 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
<?php
/**
* @remark :
* @name :AggregateKeywordAffixLogic.php
* @author :lyh
* @method :post
* @time :2025/5/27 14:21
*/
namespace App\Http\Logic\Aside\Project;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\AggregateKeywordAffix;
class AggregateKeywordAffixLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new AggregateKeywordAffix();
}
/**
* @remark :保存数据
* @name :getAffix
* @author :lyh
* @method :post
* @time :2025/5/27 14:25
*/
public function getAffix(){
$data = $this->model->read(['project_id'=>$this->param['project_id']]);
if($data === false){
$data = [];
}
return $this->success($data);
}
/**
* @remark :保存数据
* @name :saveAffix
* @author :lyh
* @method :post
* @time :2025/5/27 14:28
*/
public function saveAffix(){
$info = $this->model->read(['project_id'=>$this->param['project_id']]);
try {
if($info === false){
$this->model->addReturnId(['project_id'=>$this->param['project_id'],'prefix'=>$this->param['prefix'] ?? '','suffix'=>$this->param['suffix'] ?? '']);
}else{
$this->model->edit(['prefix'=>$this->param['prefix'] ?? '','suffix'=>$this->param['suffix'] ?? ''],['project_id'=>$this->param['project_id']]);
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
}