AiCommandLogic.php 2.4 KB
<?php

namespace App\Http\Logic\Aside\Ai;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Ai\AiCommand as AiCommandModel;

class AiCommandLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();

        $this->model = new AiCommandModel();
        $this->param = $this->requestAll;
    }

    /**
     * @name :详情
     * @return void
     * @author :liyuhang
     * @method
     */
    public function ai_info(){
        $info = $this->model->read($this->param);
        if($info === false){
            $this->fail('当前数据不存在');
        }
        return $this->success($info);
    }

    /**
     * @name :添加指令
     * @return void
     * @author :liyuhang
     * @method
     */
    public function ai_add(){
        $condition = [
            'key'=>$this->param['key']
        ];
        $info = $this->model->read($condition);
        if($info !== false){
            $this->fail('当前指令已存在');
        }
        $this->param['operator_id'] = $this->manager['id'];
        $this->param['create_id'] = $this->manager['id'];
        $rs = $this->model->add($this->param);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @name :编辑站内信
     * @return void
     * @author :liyuhang
     * @method
     */
    public function ai_edit(){
        $condition = [
            'id'=>['!=',$this->param['id']],
            'key'=>$this->param['key']
        ];
        $info = $this->model->read($condition);
        if($info !== false){
            $this->fail('当前编辑的指令key已存在');
        }
        $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @name :删除站内信
     * @return void
     * @author :liyuhang
     * @method
     */
    public function ai_del(){
        $this->param['id'] = ['in',$this->param['id']];
        $rs = $this->model->del($this->param);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @remark :参数处理
     * @name   :paramHandle
     * @author :lyh
     * @method :post
     * @time   :2023/6/26 11:10
     */
    public function paramHandle($param){
        $param[''] = 1;
    }
}