AggregateKeywordAffixLogic.php 1.6 KB
<?php
/**
 * @remark :
 * @name   :AggregateKeywordAffixLogic.php
 * @author :lyh
 * @method :post
 * @time   :2025/5/27 14:21
 */

namespace App\Http\Logic\Aside\Project;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\AggregateKeywordAffix;

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

    /**
     * @remark :保存数据
     * @name   :getAffix
     * @author :lyh
     * @method :post
     * @time   :2025/5/27 14:25
     */
    public function getAffix(){
        $data = $this->model->read(['project_id'=>$this->param['project_id']]);
        return $this->success($data);
    }

    /**
     * @remark :保存数据
     * @name   :saveAffix
     * @author :lyh
     * @method :post
     * @time   :2025/5/27 14:28
     */
    public function saveAffix(){
        $info = $this->model->read(['project_id'=>$this->param['project_id']]);
        try {
            if($info === false){
                $this->model->addReturnId(['project_id'=>$this->param['project_id'],'prefix'=>$this->param['prefix'] ?? '','suffix'=>$this->param['suffix'] ?? '']);
            }else{
                $this->model->edit(['prefix'=>$this->param['prefix'] ?? '','suffix'=>$this->param['suffix'] ?? ''],['project_id'=>$this->param['project_id']]);
            }
        }catch (\Exception $e){
            $this->fail('保存失败,请联系管理员');
        }
        return $this->success();
    }
}