WebSettingLogic.php 1.7 KB
<?php

namespace App\Http\Logic\Bside\Setting;

use App\Helper\Common as CommonHelper;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSetting;

class WebSettingLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->model = new WebSetting();
        $this->param = $this->requestAll;
    }

    /**
     * @name   :(获取首页设置)setting_read
     * @author :lyh
     * @method :post
     * @time   :2023/4/28 15:14
     */
    public function setting_read(){
        $info = $this->model->read(['project_id'=>$this->user['project_id']]);
        if($info === false){
            $this->model->addReturnId(['project_id'=>$this->user['project_id']]);
            $info =$this->model->read(['project_id'=>$this->user['project_id']]);
        }
        return $this->success($info);
    }

    /**
     * @name   :(添加或编辑)setting_save
     * @author :lyh
     * @method :post
     * @time   :2023/4/28 15:18
     */
    public function setting_save(){
        if(isset($this->param['is_custom_anchor'])){
            $this->param['is_custom_anchor'] = json_encode($this->param['is_custom_anchor'],true);
        }
        //查看数据是否存在
        $info = $this->model->read(['project_id'=>$this->user['project_id']]);
        if($info === false){
            $this->param['project_id'] = $this->user['project_id'];
            $rs = $this->model->add($this->param);
        }else{
            $rs = $this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
        }
        if($rs === false){
            $this->fail('error');
        }
        CommonHelper::del_user_cache($this->model->getTable(),$this->user['project_id']);
        return $this->success();
    }




}