Files
sentcms/app/controller/admin/Menu.php
molong 0b0d659c5e tp6更新到最新版本
目录结构调整
2019-09-12 23:57:10 +08:00

81 lines
1.8 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\admin;
use app\controller\Admin;
use app\Model\Menu as MenuModel;
class Menu extends Admin{
/**
* @title 系统首页
*/
public function index(){
if($this->request->isAjax()){
$menu = new MenuModel();
$map = array();
$res = $menu->where($map)->order('sort asc, id asc')->select();
$this->data['data'] = $res;
return $this->data;
}
}
/**
* @title 编辑菜单
*/
public function edit(){
$menu = new MenuModel();
if($this->request->isAjax()){
$data = $this->request->post();
$result = $menu->where('id', $data['id'])->save($data);
if (false !== $result) {
$this->data['code'] = 0;
$this->data['msg'] = '更新成功!';
}else{
$this->data['code'] = 1;
$this->data['msg'] = '更新失败!';
}
return $this->data;
}else{
$id = $this->request->param('id', 0);
if (!$id) {
return $this->error('非法操作!');
}
$info = $menu->where('id', $id)->find();
$this->data['data'] = array('info'=>$info);
return $this->data;
}
}
/**
* @title 添加菜单
*/
public function add(){
if($this->request->isAjax()){
return $this->data;
}else{
$this->data['template'] = 'edit';
return $this->data;
}
}
/**
* @title 移除菜单
*/
public function remove(){
if($this->request->isAjax()){
return $this->data;
}
}
}