作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WebSettingSeoController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 16:31
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Setting;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Setting\WebSettingSeoLogic;
  15 +
  16 +class WebSettingSeoController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取当前项目seo详情
  20 + * @name :info
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/9/11 16:31
  24 + */
  25 + public function info(WebSettingSeoLogic $logic){
  26 + $info = $logic->seoInfo();
  27 + $this->response('success',Code::SUCCESS,$info);
  28 + }
  29 +
  30 + /**
  31 + * @remark :保存数据
  32 + * @name :save
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/9/11 16:32
  36 + */
  37 + public function save(WebSettingSeoLogic $logic){
  38 + $logic->seoSave();
  39 + $this->response('success');
  40 + }
  41 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WebSettingSeoLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 16:32
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Setting;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\WebSetting\WebSettingSeo;
  14 +
  15 +class WebSettingSeoLogic extends BaseLogic
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->model = new WebSettingSeo();
  21 + $this->param = $this->requestAll;
  22 + }
  23 +
  24 + /**
  25 + * @remark :获取详情
  26 + * @name :seoInfo
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/9/11 16:33
  30 + */
  31 + public function seoInfo(){
  32 + $info = $this->model->read($this->param);
  33 + if($info === false){
  34 + $this->fail('当前数据不存在');
  35 + }
  36 + return $this->success($info);
  37 + }
  38 +
  39 + /**
  40 + * @remark :保存数据
  41 + * @name :save
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/9/11 16:34
  45 + */
  46 + public function seoSave(){
  47 + try {
  48 + $info = $this->model->read(['project_id'=>$this->user['project_id']]);
  49 + if($info === false){
  50 + $this->param['project_id'] = $this->user['project_id'];
  51 + $this->model->add($this->param);
  52 + }else{
  53 + $this->model->edit($this->param,['project_id'=>$this->param['project_id']]);
  54 + }
  55 + }catch (\Exception $e){
  56 + $this->fail('error');
  57 + }
  58 + return $this->success();
  59 + }
  60 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WebSettingSeo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 16:28
  8 + */
  9 +
  10 +namespace App\Models\WebSetting;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class WebSettingSeo extends Base
  15 +{
  16 + //锚文本常量配置在settingTextModel中
  17 + protected $table = 'gl_web_setting_seo';
  18 +
  19 + //连接数据库
  20 + protected $connection = 'custom_mysql';
  21 +}
@@ -160,6 +160,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -160,6 +160,12 @@ Route::middleware(['bloginauth'])->group(function () {
160 Route::any('/languageList', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'languageList'])->name('web_proofreading_languageList'); 160 Route::any('/languageList', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'languageList'])->name('web_proofreading_languageList');
161 }); 161 });
162 162
  163 + //seo设置
  164 + Route::prefix('seo')->group(function () {
  165 + Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'info'])->name('web_seo_lists');
  166 + Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'save'])->name('web_seo_save');
  167 + });
  168 +
163 }); 169 });
164 //产品 170 //产品
165 Route::prefix('product')->group(function () { 171 Route::prefix('product')->group(function () {