/** * 删除流程 * * @param $hash_id * @param $user_id * @return bool */ public function delete($hash_id, $user_id) { $workflow = Workflow::findFirst(['hash_id = :hash_id: and user_id = :user_id:', 'bind' => ['hash_id' => $hash_id, 'user_id' => $user_id]]); if ($workflow) { WorkflowVar::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); WorkflowResult::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); WorkflowLog::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); return $workflow->delete(); } else { return false; } }
/** * var */ public function varAction() { $hash_id = $this->request->get('pk', 'string', ''); $name = $this->request->get('name', 'string', ''); $value = $this->request->get('value', 'string', ''); $type = $this->request->get('type', 'string', 'add/edit'); $workflow = $this->workflow->findFirst($hash_id, $this->current_user->id); if ($workflow) { $var = WorkflowVar::findFirst(['wf_id = :wf_id: and name = :name:', 'bind' => ['wf_id' => $workflow->id, 'name' => $name]]); if ($type == 'del') { // 删除文件 if (stristr($var->value, $this->config->application->domain . '/temp/var/') !== false) { $path = str_replace($this->config->application->domain, '', $var->value); Filesystem::delete(public_path() . $path); } $var->delete(); return $this->ajaxResponse(0); } if (!$var) { $var = new WorkflowVar(); $var->wf_id = $workflow->id; } $var->name = $name; $var->value = $value; $var->save(); $error = 0; } else { $error = 1; } return $this->ajaxResponse($error); }