WebSettingSeoLogic.php 1.8 KB
<?php
/**
 * @remark :
 * @name   :WebSettingSeoLogic.php
 * @author :lyh
 * @method :post
 * @time   :2023/9/11 16:32
 */

namespace App\Http\Logic\Bside\Setting;

use App\Helper\Arr;
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(['project_id'=>$this->user['project_id']]);
        if($info === false){
            return $this->success();
        }
        return $this->success($info);
    }

    /**
     * @remark :保存数据
     * @name   :save
     * @author :lyh
     * @method :post
     * @time   :2023/9/11 16:34
     * @param  :product_category_prefix->分类页前缀;product_category_suffix->分类页后缀
     */
    public function seoSave(){
        $this->param['product_category_prefix'] = Arr::a2s($this->param['product_category_prefix'] ?? []);
        $this->param['product_category_suffix'] = Arr::a2s($this->param['product_category_suffix'] ?? []);
        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->user['project_id']]);
            }
        }catch (\Exception $e){
            $this->fail('error');
        }
        return $this->success();
    }
}