123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\controller;
-
-
- use app\admin\logic\AdminLogic;
- use app\admin\logic\LoginLogic;
- use app\admin\validate\AdminPasswordValidate;
- use app\admin\validate\AdminValidate;
- use app\common\basics\AdminBase;
- use app\common\model\Role;
- use app\common\model\Admin as AdminModel;
- use app\common\server\JsonServer;
-
- class Admin extends AdminBase
- {
-
-
- public function lists()
- {
- if ($this->request->isAjax()) {
- $get = $this->request->get();
- return JsonServer::success('获取成功', AdminLogic::lists($get));
- }
- return view('', ['role_lists' => (new Role())->getRoleLists()]);
- }
-
-
-
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
- (new AdminValidate())->goCheck('add');
- if (AdminLogic::addAdmin($post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- return view('', ['role_lists' => (new Role())->getRoleLists()]);
- }
-
-
-
- public function edit()
- {
- $id = $this->request->get('admin_id');
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
- (new AdminValidate())->goCheck('edit');
- if (AdminLogic::editAdmin($post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- return view('',[
- 'detail' => AdminModel::find($id),
- 'role_lists' => (new Role())->getRoleLists()
- ]);
- }
-
-
-
-
- public function del()
- {
- if ($this->request->isAjax()) {
- $id = $this->request->post('admin_id');
- if (AdminLogic::delAdmin($id)) {
- return JsonServer::success('操作成功');
- }
- }
- return JsonServer::error('操作失败');
- }
-
-
-
-
- public function password()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['admin_id'] = $this->adminId;
- (new AdminPasswordValidate())->goCheck('', $post);
-
- $res = AdminLogic::updatePassword($post['password'], $this->adminId);
- if ($res) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- return view('', [
- 'account' => $this->adminUser['account']
- ]);
- }
-
- }
|