作者 lyh

gx

<?php
/**
* @remark :
* @name :WebSettingSeoController.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:31
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingSeoLogic;
class WebSettingSeoController extends BaseController
{
/**
* @remark :获取当前项目seo详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/9/11 16:31
*/
public function info(WebSettingSeoLogic $logic){
$info = $logic->seoInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/11 16:32
*/
public function save(WebSettingSeoLogic $logic){
$logic->seoSave();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :WebSettingSeoLogic.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:32
*/
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingSeo;
class WebSettingSeoLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingSeo();
$this->param = $this->requestAll;
}
/**
* @remark :获取详情
* @name :seoInfo
* @author :lyh
* @method :post
* @time :2023/9/11 16:33
*/
public function seoInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在');
}
return $this->success($info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/11 16:34
*/
public function seoSave(){
try {
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}else{
$this->model->edit($this->param,['project_id'=>$this->param['project_id']]);
}
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...
<?php
/**
* @remark :
* @name :WebSettingSeo.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:28
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingSeo extends Base
{
//锚文本常量配置在settingTextModel中
protected $table = 'gl_web_setting_seo';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -160,6 +160,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/languageList', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'languageList'])->name('web_proofreading_languageList');
});
//seo设置
Route::prefix('seo')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'info'])->name('web_seo_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'save'])->name('web_seo_save');
});
});
//产品
Route::prefix('product')->group(function () {
... ...