added 新增菜单状态修改

This commit is contained in:
zhaoxiang 2018-02-04 18:27:03 +08:00
parent ca028dac85
commit 65c5d11c63
2 changed files with 19 additions and 24 deletions

View File

@ -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 <zhaoxiang051405@gmail.com>
*/
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 <zhaoxiang051405@gmail.com>
*/
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([]);
}
}

View File

@ -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'],
],
];