CreateKeywordLogic.php 1.4 KB
<?php
/**
 * @remark :
 * @name   :CreateKeywordLogic.php
 * @author :lyh
 * @method :post
 * @time   :2023/12/19 9:45
 */

namespace App\Http\Logic\Aside\Optimize;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Com\CreateKeyword;

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

    /**
     * @remark :保存关键字
     * @name   :saveCreateKeyword
     * @author :lyh
     * @method :post
     * @time   :2023/12/19 9:47
     */
    public function saveKeyword(){
        $data = $this->handleParam($this->param);
        try {
            if(isset($this->param['id']) && !empty($this->param['id'])){
                $this->model->edit($data,['id'=>$this->param['id']]);
            }else{
                $this->model->add($data);
            }
        }catch (\Exception $e){
            $this->fail('保存失败,请联系管理员');
        }
        return $this->success();
    }

    /**
     * @remark :请求参数处理
     * @name   :handleParam
     * @author :lyh
     * @method :post
     * @time   :2023/12/19 10:03
     */
    public function handleParam($param){
        $data = [
            'type'=>$param['type'],
            'name'=>$param['name']
        ];
        return $this->success($data);
    }

}