SettingFaqLogic.php 2.6 KB
<?php
/**
 * @remark :
 * @name   :SettingFaqLogic.php
 * @author :lyh
 * @method :post
 * @time   :2025/10/29 16:34
 */

namespace App\Http\Logic\Bside\Setting;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\SettingFaq;

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

    /**
     * @remark :获取数据
     * @name   :getRouteList
     * @author :lyh
     * @method :post
     * @time   :2025/10/30 09:36
     */
    public function getRouteList($map = [])
    {
        $routeModel = new RouteMap();
        $list = $routeModel->list($map,'id',['*'],'desc',20);
        return $this->success($list);
    }

    /**
     * @remark :获取列表页数据
     * @name   :getFaqLists
     * @author :lyh
     * @method :post
     * @time   :2025/10/29 16:50
     */
    public function getFaqLists($map = [],$page = 1, $row = 10,$order = 'id')
    {
        $lists = $this->model->lists($map,$page,$row,$order);
        return $this->success($lists);
    }

    /**
     * @remark :获取详情数据
     * @name   :getFaqById
     * @author :lyh
     * @method :post
     * @time   :2025/10/30 09:29
     */
    public function getFaqInfo(){
        $data = $this->model->read($this->param);
        return $this->success($data);
    }

    /**
     * @remark :保存数据
     * @name   :saveFaq
     * @author :lyh
     * @method :post
     * @time   :2025/10/29 16:50
     */
    public function saveFaq()
    {
        //todo::根据路由获取对应数据详情
        $routeModel = new RouteMap();
        $routeInfo = $routeModel->read(['route'=>$this->param['route']],['source','source_id']);
        if($routeInfo === false){
            $this->fail('路由不存在');
        }
        $this->param['qa'] = json_encode($this->param['qa'],true);
        $this->param['source'] = $routeInfo['source'];
        $this->param['source_id'] = $routeInfo['source_id'];
        if(isset($this->param['id']) && !empty($this->param['id'])){
            $id = $this->param['id'];
            $this->model->edit($this->param,['id'=>$id]);
        }else{
            $id = $this->model->addReturnId($this->param);
        }
        return $this->success(['id' => $id]);
    }

    /**
     * @remark :删除数据
     * @name   :deleteFaq
     * @author :lyh
     * @method :post
     * @time   :2025/10/29 17:27
     */
    public function deleteFaq(){
        $this->model->del(['id'=>['in',$this->param['id']]]);
        return $this->success();
    }
}