作者 lyh

gx聚合页关键字前后缀

<?php
/**
* @remark :
* @name :AggregateKeywordAffixController.php
* @author :lyh
* @method :post
* @time :2025/5/27 14:20
*/
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\AggregateKeywordAffixLogic;
use Illuminate\Http\Request;
class AggregateKeywordAffixController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->logic = new AggregateKeywordAffixLogic();
}
/**
* @remark :获取当前项目关键字前后缀
* @name :getAffix
* @author :lyh
* @method :post
* @time :2025/5/27 14:23
*/
public function getAffix(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
$data = $this->logic->getAffix();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存关键字前后缀
* @name :save
* @author :lyh
* @method :post
* @time :2025/5/27 14:23
*/
public function saveAffix(){
$this->request->validate([
'project_id'=>'required',
'prefix'=>'required',
'suffix'=>'required',
],[
'project_id.required' => 'project_id不能为空',
'prefix.required' => '前缀不能为空',
'suffix.required' => '后缀不能为空',
]);
$data = $this->logic->saveAffix();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?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']]);
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();
}
}
... ...
<?php
/**
* @remark :
* @name :AggregateKeywordAffix.php
* @author :lyh
* @method :post
* @time :2025/5/27 14:16
*/
namespace App\Models\Project;
use App\Models\Base;
/**
* @remark :聚合页关键字前后缀
* @name :AggregateKeywordAffix
* @author :lyh
* @method :post
* @time :2025/5/27 14:16
*/
class AggregateKeywordAffix extends Base
{
protected $table = 'gl_aggregate_keyword_affix';
}
... ...
... ... @@ -220,6 +220,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/', [Aside\Project\MinorLanguagesController::class, 'getMinorLanguageList'])->name('admin.getMinorLanguageList');
Route::any('/getLanguages', [Aside\Project\MinorLanguagesController::class, 'getLanguages'])->name('admin.getLanguages');
});
//更新项目tdk
Route::any('/updateSeoTdk', [Aside\Com\UpdateController::class, 'updateSeoTdk'])->name('admin.project_updateSeoTdk');
//项目内容采集
... ... @@ -562,6 +563,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/info', [Aside\Project\AggregateKeywordController::class, 'info'])->name('admin.aggregateKeyword_info');
Route::any('/save', [Aside\Project\AggregateKeywordController::class, 'save'])->name('admin.aggregateKeyword_save');
Route::any('/del', [Aside\Project\AggregateKeywordController::class, 'del'])->name('admin.aggregateKeyword_del');
//聚合页关键词前后缀
Route::prefix('affix')->group(function () {
Route::any('/getAffix', [Aside\Project\AggregateKeywordAffixController::class, 'getAffix'])->name('admin.affix_getAffix');
Route::any('/saveAffix', [Aside\Project\AggregateKeywordAffixController::class, 'saveAffix'])->name('admin.affix_saveAffix');
});
});
});
... ...