From 18de280fc7240d43a8ce59043c859ee021b73614 Mon Sep 17 00:00:00 2001 From: zhaoxiang Date: Tue, 13 Mar 2018 17:31:32 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E6=88=90=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E6=9D=83=E9=99=90=E5=A6=A5=E5=96=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/InterfaceList.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/application/admin/controller/InterfaceList.php b/application/admin/controller/InterfaceList.php index 88e2d83..72d55f1 100644 --- a/application/admin/controller/InterfaceList.php +++ b/application/admin/controller/InterfaceList.php @@ -8,6 +8,7 @@ namespace app\admin\controller; +use app\model\AdminApp; use app\model\AdminFields; use app\model\AdminList; use app\util\ReturnCode; @@ -105,7 +106,7 @@ class InterfaceList extends Base { } /** - * 编辑应用 + * 编辑接口 * @return array * @author zhaoxiang */ @@ -122,6 +123,7 @@ class InterfaceList extends Base { /** * 删除接口 * @return array + * @throws \think\exception\DbException * @author zhaoxiang */ public function del() { @@ -129,6 +131,29 @@ class InterfaceList extends Base { if (!$hash) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数'); } + + $hashRule = AdminApp::all([ + 'app_api' => ['like', "%$hash%"] + ]); + if ($hashRule) { + $oldInfo = AdminList::get(['hash' => $hash]); + foreach ($hashRule as $rule) { + $appApiArr = explode(',', $rule->app_api); + $appApiIndex = array_search($hash, $appApiArr); + array_splice($appApiArr, $appApiIndex, 1); + $rule->app_api = implode(',', $appApiArr); + + $appApiShowArrOld = json_decode($rule->app_api_show, true); + $appApiShowArr = $appApiShowArrOld[$oldInfo->groupHash]; + $appApiShowIndex = array_search($hash, $appApiShowArr); + array_splice($appApiShowArr, $appApiShowIndex, 1); + $appApiShowArrOld[$oldInfo->groupHash] = $appApiShowArr; + $rule->app_api_show = json_encode($appApiShowArrOld); + + $rule->save(); + } + } + AdminList::destroy(['hash' => $hash]); AdminFields::destroy(['hash' => $hash]);