123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shop\controller;
-
- use app\shop\logic\RoleLogic;
- use app\shop\validate\RoleValidate;
- use app\common\basics\ShopBase;
- use app\common\server\JsonServer;
-
- class Role extends ShopBase
- {
-
-
- public function lists()
- {
- if ($this->request->isAjax()) {
- $get = $this->request->get();
- return JsonServer::success('', RoleLogic::lists($this->shop_id, $get));
- }
- return view();
- }
-
-
-
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- (new RoleValidate())->goCheck('add');
- $result = RoleLogic::addRole($this->shop_id, $post);
- if ($result !== true) {
- return JsonServer::error(RoleLogic::getError() ?: '操作失败');
- }
- return JsonServer::success('操作成功');
- }
- return view('', [
- 'auth_tree' => json_encode(RoleLogic::authTree(), true)
- ]);
- }
-
-
-
-
- public function edit($role_id = '')
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- (new RoleValidate())->goCheck('edit');
- $result = RoleLogic::editRole($this->shop_id, $post);
- if ($result !== true) {
- return JsonServer::error(RoleLogic::getError() ?: '操作失败');
- }
- return JsonServer::success('操作成功');
- }
- $auth_tree = RoleLogic::authTree($role_id);
-
- return view('', [
- 'info' => RoleLogic::roleInfo($role_id),
- 'auth_tree' => json_encode($auth_tree),
- ]);
- }
-
-
-
- public function del($id)
- {
- if ($this->request->isAjax()) {
- (new RoleValidate())->goCheck('del');
- RoleLogic::delRole($this->shop_id, $id);
- return JsonServer::success('删除成功');
- }
- }
- }
|