|
...
|
...
|
@@ -37,12 +37,26 @@ class AiCommandLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function ai_add(){
|
|
|
|
$condition = [
|
|
|
|
'key'=>$this->param['key']
|
|
|
|
'key'=>$this->param['key'],
|
|
|
|
'project_id'=>$this->param['project_id']??0,
|
|
|
|
];
|
|
|
|
$info = $this->model->read($condition);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前指令已存在');
|
|
|
|
}
|
|
|
|
if($condition['project_id']){
|
|
|
|
$where = [
|
|
|
|
'key'=>$this->param['key'],
|
|
|
|
'project_id'=>0,
|
|
|
|
'is_batch'=>1,
|
|
|
|
];
|
|
|
|
$valid_key = $this->model->read($where);
|
|
|
|
if(!$valid_key){
|
|
|
|
$this->fail('指令字段不正确');
|
|
|
|
}
|
|
|
|
$this->param['is_batch'] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->param['operator_id'] = $this->manager['id'];
|
|
|
|
$this->param['create_id'] = $this->manager['id'];
|
|
|
|
$rs = $this->model->add($this->param);
|
|
...
|
...
|
@@ -61,12 +75,25 @@ class AiCommandLogic extends BaseLogic |
|
|
|
public function ai_edit(){
|
|
|
|
$condition = [
|
|
|
|
'id'=>['!=',$this->param['id']],
|
|
|
|
'key'=>$this->param['key']
|
|
|
|
'key'=>$this->param['key'],
|
|
|
|
'project_id'=>$this->param['project_id']??0,
|
|
|
|
];
|
|
|
|
$info = $this->model->read($condition);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前编辑的指令key已存在');
|
|
|
|
}
|
|
|
|
if($condition['project_id']){
|
|
|
|
$where = [
|
|
|
|
'key'=>$this->param['key'],
|
|
|
|
'project_id'=>0,
|
|
|
|
'is_batch'=>1,
|
|
|
|
];
|
|
|
|
$valid_key = $this->model->read($where);
|
|
|
|
if(!$valid_key){
|
|
|
|
$this->fail('指令字段不正确');
|
|
|
|
}
|
|
|
|
$this->param['is_batch'] = 1;
|
|
|
|
}
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
...
|
...
|
|