From 55268df76157e371ed53527878199385947e5d63 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Wed, 14 Mar 2018 01:39:32 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E6=88=90=E8=A7=84=E5=88=99?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=96=B9=E7=BC=93=E5=AD=98=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Fields.php | 21 +++++++++++++++++++ .../admin/controller/InterfaceList.php | 8 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/Fields.php b/application/admin/controller/Fields.php index 1aaca74..dbfea56 100644 --- a/application/admin/controller/Fields.php +++ b/application/admin/controller/Fields.php @@ -97,6 +97,11 @@ class Fields extends Base { $postData['default'] = $postData['defaults']; unset($postData['defaults']); $res = AdminFields::create($postData); + + cache('RequestFields:NewRule:' . $postData['hash'], null); + cache('RequestFields:Rule:' . $postData['hash'], null); + cache('ResponseFieldsRule:' . $postData['hash'], null); + if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -115,6 +120,11 @@ class Fields extends Base { $postData['default'] = $postData['defaults']; unset($postData['defaults']); $res = AdminFields::update($postData); + + cache('RequestFields:NewRule:' . $postData['hash'], null); + cache('RequestFields:Rule:' . $postData['hash'], null); + cache('ResponseFieldsRule:' . $postData['hash'], null); + if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { @@ -126,12 +136,19 @@ class Fields extends Base { * 字段删除 * @author zhaoxiang * @return array + * @throws \think\exception\DbException */ public function del() { $id = $this->request->get('id'); if (!$id) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + + $fieldsInfo = AdminFields::get($id); + cache('RequestFields:NewRule:' . $fieldsInfo->hash, null); + cache('RequestFields:Rule:' . $fieldsInfo->hash, null); + cache('ResponseFieldsRule:' . $fieldsInfo->hash, null); + AdminFields::destroy($id); return $this->buildSuccess([]); @@ -178,6 +195,10 @@ class Fields extends Base { (new AdminFields())->insertAll($addData); } + cache('RequestFields:NewRule:' . $hash, null); + cache('RequestFields:Rule:' . $hash, null); + cache('ResponseFieldsRule:' . $hash, null); + return $this->buildSuccess([]); } diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 72d55f1..852b9aa 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -91,16 +91,17 @@ class InterfaceList extends Base { * @author zhaoxiang */ public function changeStatus() { - $id = $this->request->get('id'); + $hash = $this->request->get('hash'); $status = $this->request->get('status'); $res = AdminList::update([ 'status' => $status ], [ - 'id' => $id + 'hash' => $hash ]); if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { + cache('ApiInfo:' . $hash, null); return $this->buildSuccess([]); } } @@ -116,6 +117,7 @@ class InterfaceList extends Base { if ($res === false) { return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { + cache('ApiInfo:' . $postData['hash'], null); return $this->buildSuccess([]); } } @@ -157,6 +159,8 @@ class InterfaceList extends Base { AdminList::destroy(['hash' => $hash]); AdminFields::destroy(['hash' => $hash]); + cache('ApiInfo:' . $hash, null); + return $this->buildSuccess([]); }