['请求方法' => ['字段1','字段2'],], // 'post' => ['add' => ['data']] ]; // public function read() // { // try { // $Examine_model = new \app\admin\model\Examine(); // $result = $Examine_model->read($_GET); // tojson(200, '请求成功', $result); // } catch (\Exception $e) { // tojson(10000, $e->getMessage()); // } catch (\Throwable $e) { // tojson(10000, $e->getMessage()); // } // } public function getAll() { try { $Examine_model = new \app\admin\model\Examine(); $result = $Examine_model->getAll($_GET, $this->request->page, $this->request->pageSize); tojson(200, '请求成功', $result); } catch (\Exception $e) { tojson(10000, $e->getMessage()); } catch (\Throwable $e) { tojson(10000, $e->getMessage()); } } public function save() { try { $Collection_model = new \app\admin\model\Collection(); $check = $Collection_model->where($Collection_model->getPk(), $_POST['collection_id'])->field('appoint_id,customer_id')->find(); if (!$check) { tojson(10000, '记录不存在'); } if ($_POST['status'] == 1) { if (!isset($_POST['reason']) || empty($_POST['reason'])) { tojson(10000, 'reason不存在'); } } $_POST['user_id'] = $this->userInfo['id']; $Examine_model = new \app\admin\model\Examine(); $_POST = array_merge($check->toArray(), $_POST); $check = $Examine_model->where('collection_id', $_POST['collection_id'])->value($Examine_model->getPk()); if ($check) { $result = $Examine_model->save($_POST, ['collection_id' => $_POST['collection_id']]); } else { $result = $Examine_model->save($_POST); } if ($result) { tojson(200, '添加成功'); } else { tojson(10000, '添加失败'); } } catch (\Exception $e) { tojson(10000, $e->getMessage()); } catch (\Throwable $e) { tojson(10000, $e->getMessage()); } } public function update() { try { $Examine_model = new \app\admin\model\Examine(); $check = $Examine_model->where('collection_id', $this->param['collection_id'])->value($Examine_model->getPk()); if (!$check) { tojson(10000, '记录不存在'); } if ($this->param['status'] == 1) { if (!isset($this->param['reason']) || empty($this->param['reason'])) { tojson(10000, 'reason不存在'); } } $this->param['user_id'] = $this->userInfo['id']; unset($this->param['appoint_id']); unset($this->param['customer_id']); unset($this->param['id']); $result = $Examine_model->save($this->param, [$Examine_model->getPk() => $this->param['collection_id']]); if ($result) { tojson(200, '修改成功'); } else { tojson(10000, '修改失败'); } } catch (\Exception $e) { tojson(10000, $e->getMessage()); } catch (\Throwable $e) { tojson(10000, $e->getMessage()); } } // public function delete() // { // try { // $Examine_model = new \app\admin\model\Examine(); // $check = $Examine_model->where($Examine_model->getPk(), $this->param[$Examine_model->getPk()])->value($Examine_model->getPk()); // if (!$check) { // tojson(10000, '记录不存在'); // } // $result = $Examine_model->where($Examine_model->getPk(), $this->param[$Examine_model->getPk()])->delete(); // if ($result) { // tojson(200, '删除成功'); // } else { // tojson(10000, '删除失败'); // } // } catch (\Exception $e) { // tojson(10000, $e->getMessage()); // } catch (\Throwable $e) { // tojson(10000, $e->getMessage()); // } // } }