123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shop\controller;
-
-
- use app\shop\logic\AdminLogic;
- use app\shop\validate\AdminPasswordValidate;
- use app\shop\validate\AdminValidate;
- use app\common\basics\ShopBase;
- use app\common\model\shop\ShopRole;
- use app\common\model\shop\ShopAdmin;
- use app\common\server\JsonServer;
-
- class Admin extends ShopBase
- {
-
-
- public function lists()
- {
- if ($this->request->isAjax()) {
- $get = $this->request->get();
- return JsonServer::success('获取成功', AdminLogic::lists($get, $this->shop_id));
- }
- return view('', ['role_lists' => (new ShopRole())->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($this->shop_id, $post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- return view('', [
- 'role_lists' => (new ShopRole())->getRoleLists(['shop_id' => $this->shop_id])
- ]);
- }
-
-
-
- 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($this->shop_id, $post)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- return view('', [
- 'detail' => ShopAdmin::find($id),
- 'role_lists' => (new ShopRole())->getRoleLists(['shop_id' => $this->shop_id])
- ]);
- }
-
-
-
-
- public function del()
- {
- if ($this->request->isAjax()) {
- $id = $this->request->post('admin_id');
- if (AdminLogic::delAdmin($this->shop_id, $id)) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '操作失败');
- }
- }
-
-
-
-
-
- public function password()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['admin_id'] = $this->admin_id;
- (new AdminPasswordValidate())->goCheck('', $post);
- $res = AdminLogic::updatePassword($post['password'], $this->admin_id, $this->shop_id);
- if ($res) {
- return JsonServer::success('操作成功');
- }
- return JsonServer::error(AdminLogic::getError() ?: '系统错误');
- }
- return view('', [
- 'account' => $this->shop['account']
- ]);
- }
-
- }
|