GeoLogic.php 2.2 KB
<?php
/**
 * @remark :
 * @name   :GeoLogic.php
 * @author :lyh
 * @method :post
 * @time   :2025/7/2 17:51
 */

namespace App\Http\Logic\Aside\Geo;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoQuestion;
use App\Models\Project\Project;

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

    /**
     * @remark :设置geo状态
     * @name   :setGeoStatus
     * @author :lyh
     * @method :post
     * @time   :2025/7/2 17:51
     */
    public function setGeoStatus(){
        $projectModel = new Project();
        $data = $projectModel->edit(['geo_status'=>$this->param['geo_status'],'geo_frequency'=>$this->param['geo_frequency']],['id'=>$this->param['project_id']]);
        return $this->success($data);
    }

    /**
     * @remark :获取问题列表
     * @name   :getGeoQuestionList
     * @author :lyh
     * @method :post
     * @time   :2025/7/3 9:12
     */
    public function getGeoQuestionList($map,$page,$row,$order,$field = ['*']){
        $data = $this->model->lists($map,$page,$row,$order,$field);
        return $this->success($data);
    }

    /**
     * @remark :保存数据
     * @name   :saveGeoQuestion
     * @author :lyh
     * @method :post
     * @time   :2025/7/3 9:47
     * @param  : question->提交的问题
     * @param  : url->提交的网址
     * @param  : keywords->提交的关键字
     */
    public function saveGeoQuestion(){
        //处理数据
        $this->param['question'] = json_encode($this->param['question'] ?? [],true);
        $this->param['url'] = json_encode($this->param['url'] ?? [],true);
        $this->param['keywords'] = json_encode($this->param['keywords'] ?? [],true);
        //执行时间设置为今天
        $this->param['current_time'] = date('Y-m-d');
        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]);
    }
}