123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\controller;
-
-
- use app\admin\validate\AuthValidate;
- use app\admin\logic\AuthLogic;
- use app\common\basics\AdminBase;
- use app\common\server\JsonServer;
- use think\facade\View;
-
- class Auth extends AdminBase
- {
-
-
- public function lists()
- {
- if($this->request->isAjax()) {
- $data = AuthLogic::lists();
- return json(['code' => 0, 'msg' => '列表', 'data' => json_encode($data)]);
- }
- return view();
- }
-
-
-
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
- (new AuthValidate())->goCheck();
- $result = AuthLogic::addMenu($post);
- if (false === $result) {
- return JsonServer::error(AuthLogic::getError() ?: '操作失败');
- }
- return JsonServer::success('操作成功');
- }
- return view('', ['menu_lists' => AuthLogic::chooseMenu()]);
- }
-
-
-
- public function edit()
- {
- $id = $this->request->get('id');
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
- (new AuthValidate())->goCheck();
- if (false === AuthLogic::editMenu($post)) {
- return JsonServer::error(AuthLogic::getError() ?: '操作失败');
- }
- return JsonServer::success('操作成功');
- }
-
- return view('', [
- 'detail' => AuthLogic::detail($id)->toArray(),
- 'menu_lists' => AuthLogic::chooseMenu()
- ]);
- }
-
-
-
-
- public function del()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- if (empty($post['ids'])) {
- return JsonServer::error(AuthLogic::getError() ?: '操作失败');
- }
- AuthLogic::delMenu($post['ids']);
- return JsonServer::success('操作成功');
- }
- }
-
-
-
-
- public function status()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- AuthLogic::setStatus($post);
- return JsonServer::success('操作成功');
- }
- }
- }
|