tp6更新到最新版本
目录结构调整
This commit is contained in:
@@ -17,9 +17,9 @@ use think\facade\Cache;
|
||||
class Admin extends BaseController {
|
||||
|
||||
protected $middleware = [
|
||||
'\app\middleware\Validate',
|
||||
'\app\middleware\AdminAuth' => ['except' => ['login']],
|
||||
'\app\middleware\Admin'
|
||||
'\app\http\middleware\Validate',
|
||||
'\app\http\middleware\AdminAuth' => ['except' => ['login']],
|
||||
'\app\http\middleware\Admin'
|
||||
];
|
||||
|
||||
protected $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
@@ -33,17 +33,17 @@ class Admin extends BaseController {
|
||||
$this->data['config'] = $config;
|
||||
}
|
||||
|
||||
protected function success($msg, $url){
|
||||
protected function success($msg, $url = ''){
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url->__toString();
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
protected function error($msg, $url){
|
||||
protected function error($msg, $url = ''){
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url->__toString();
|
||||
$this->data['url'] = $url ? $url->__toString() : '';
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use app\BaseController;
|
||||
|
||||
class Index extends BaseController {
|
||||
|
||||
protected $middleware = ['\app\middleware\Front'];
|
||||
protected $middleware = ['\app\http\middleware\Front'];
|
||||
|
||||
/**
|
||||
* @title 网站首页
|
||||
|
||||
@@ -16,6 +16,17 @@ class Group extends Admin{
|
||||
* @title 系统首页
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
if ($this->request->isAjax()) {
|
||||
# code...
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 权限列表
|
||||
*/
|
||||
public function access(){
|
||||
if ($this->request->isAjax()) {
|
||||
# code...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,7 @@ class Index extends Admin{
|
||||
public function logout(){
|
||||
Session::set('user', null);
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = "成功退出!";
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ class Menu extends Admin{
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$menu = new MenuModel();
|
||||
$map = array();
|
||||
|
||||
$res = $menu->select();
|
||||
$res = $menu->where($map)->order('sort asc, id asc')->select();
|
||||
|
||||
$this->data['data'] = $res;
|
||||
return $this->data;
|
||||
@@ -31,14 +32,28 @@ class Menu extends Admin{
|
||||
* @title 编辑菜单
|
||||
*/
|
||||
public function edit(){
|
||||
$menu = new MenuModel();
|
||||
if($this->request->isAjax()){
|
||||
$menu = new MenuModel();
|
||||
$data = $this->request->post();
|
||||
|
||||
$res = $menu->select();
|
||||
|
||||
$this->data['data'] = $res;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -48,11 +63,6 @@ class Menu extends Admin{
|
||||
*/
|
||||
public function add(){
|
||||
if($this->request->isAjax()){
|
||||
$menu = new MenuModel();
|
||||
|
||||
$res = $menu->select();
|
||||
|
||||
$this->data['data'] = $res;
|
||||
return $this->data;
|
||||
}else{
|
||||
$this->data['template'] = 'edit';
|
||||
@@ -65,11 +75,6 @@ class Menu extends Admin{
|
||||
*/
|
||||
public function remove(){
|
||||
if($this->request->isAjax()){
|
||||
$menu = new MenuModel();
|
||||
|
||||
$res = $menu->select();
|
||||
|
||||
$this->data['data'] = $res;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user