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([]); }