From 65c5d11c6363574922c1b52971353e0a7334ab91 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Sun, 4 Feb 2018 18:27:03 +0800 Subject: [PATCH] =?UTF-8?q?added=20=E6=96=B0=E5=A2=9E=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Menu.php | 31 ++++++++++----------------- application/adminRoute.php | 12 +++++++---- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php index fb295e4..ed1bc06 100644 --- a/application/admin/controller/Menu.php +++ b/application/admin/controller/Menu.php @@ -9,6 +9,7 @@ namespace app\admin\controller; use app\model\ApiMenu; +use app\util\ReturnCode; class Menu extends Base { @@ -56,30 +57,20 @@ class Menu extends Base { } /** - * 显示菜单 + * 菜单状态编辑 * @author zhaoxiang */ - public function open() { - $id = I('post.id'); - $res = D('ApiMenu')->where(array('id' => $id))->save(array('hide' => 0)); + public function changeStatus() { + $id = $this->request->get('id'); + $status = $this->request->get('status'); + $res = ApiMenu::update([ + 'id' => $id, + 'hide' => $status + ]); if ($res === false) { - $this->ajaxError('操作失败'); + return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败'); } else { - $this->ajaxSuccess('添加成功'); - } - } - - /** - * 隐藏菜单 - * @author zhaoxiang - */ - public function close() { - $id = I('post.id'); - $res = D('ApiMenu')->where(array('id' => $id))->save(array('hide' => 1)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); + return $this->buildSuccess([]); } } diff --git a/application/adminRoute.php b/application/adminRoute.php index 50c2216..57695dc 100644 --- a/application/adminRoute.php +++ b/application/adminRoute.php @@ -3,18 +3,22 @@ $afterBehavior = ['\app\admin\behavior\ApiAuth', '\app\admin\behavior\ApiPermiss return [ '[admin]' => [ - 'Login/index' => [ + 'Login/index' => [ 'admin/Login/index', ['method' => 'post'] ], - 'Login/logout' => [ + 'Login/logout' => [ 'admin/Login/logout', ['method' => 'get'] ], - 'Menu/index' => [ + 'Menu/index' => [ 'admin/Menu/index', ['method' => 'get', 'after_behavior' => $afterBehavior] ], - '__miss__' => ['admin/Miss/index'], + 'Menu/changeStatus' => [ + 'admin/Menu/changeStatus', + ['method' => 'get', 'after_behavior' => $afterBehavior] + ], + '__miss__' => ['admin/Miss/index'], ], ];