| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- <?php
 
- namespace app\admin\controller;
 
- use app\admin\common\AdminController;
 
- use app\admin\api\RoleApi;
 
- /**
 
-  * Description of Role
 
-  *
 
-  * @author sgq
 
-  */
 
- class Role extends AdminController {
 
-     /**
 
-      * @auth {{/role}}
 
-      * @return type
 
-      */
 
-     public function index() {
 
-         return view();
 
-     }
 
-     /**
 
-      * @auth {{/role/list}}
 
-      * @return type
 
-      */
 
-     public function list() {
 
-         $list = RoleApi::getList($this->request->param());
 
-         return json($list);
 
-     }
 
-     /**
 
-      * @auth {{/role/add}}
 
-      * @return type
 
-      */
 
-     public function add() {
 
-         if ($this->request->isPost()) {
 
-             return json(RoleApi::create($this->request->param()));
 
-         }
 
-         return view();
 
-     }
 
-     /**
 
-      * @auth {{/role/edit}}
 
-      * @return type
 
-      */
 
-     public function edit() {
 
-         if ($this->request->isPost()) {
 
-             return json(RoleApi::update($this->request->param()));
 
-         }
 
-         $id = $this->request->param("id");
 
-         return view("", ["role" => RoleApi::getOne($id)]);
 
-     }
 
-     /**
 
-      * @auth {{/role/role_edit}}
 
-      */
 
-     public function role_edit() {
 
-         
 
-     }
 
-     /**
 
-      * @auth {{/role/role_assign}}
 
-      * @return type
 
-      */
 
-     public function assign() {
 
-         $role = RoleApi::getOne($this->request->param("id"));
 
-         return view("", ["role" => $role]);
 
-     }
 
-     /**
 
-      * @auth {{/role/setAuthority}}
 
-      */
 
-     public function set_authority() {
 
-         if ($this->request->isPost()) {
 
-             return json(RoleApi::set_authority($this->request["roleId"], $this->request["ids"]));
 
-         }
 
-     }
 
-     /**
 
-      * @auth {{/role/remove}}
 
-      */
 
-     public function delete() {
 
-         if ($this->request->isPost()) {
 
-             return json(RoleApi::delete($this->request->param("roleId")));
 
-         }
 
-     }
 
-     function roleTreeListByUserId() {
 
-         $userId = $this->request->param("userId");
 
-         $user = \app\admin\api\UserApi::getOne($userId);
 
-         $roleIds = array_filter(explode(",", $user["roleid"]));
 
-         $list = getTreeList(RoleApi::getList([]));
 
-         $format_list = [];
 
-         foreach ($list as $item) {
 
-             $format_list[] = [
 
-                 "checked" => in_array($item["id"], $roleIds) ? true : false,
 
-                 "id" => $item["id"],
 
-                 "isOpen" => true,
 
-                 "name" => $item["name"],
 
-                 "open" => $item["pid"] == 0 ? true : false,
 
-                 "pId" => $item["pid"]
 
-             ];
 
-         }
 
-         return $format_list;
 
-     }
 
-     function treelist() {
 
-         $list = getTreeList(RoleApi::getList([]));
 
-         $format_list = [];
 
-         foreach ($list as $item) {
 
-             $format_list[] = [
 
-                 "checked" => false,
 
-                 "id" => $item["id"],
 
-                 "isOpen" => true,
 
-                 "name" => $item["name"],
 
-                 "open" => $item["pid"] == 0 ? true : false,
 
-                 "pId" => $item["pid"]
 
-             ];
 
-         }
 
-         $format_list[] = ["checked" => true, "id" => "0", "isOpen" => true, "name" => "顶级", "open" => true, "pId" => "0"];
 
-         return $format_list;
 
-     }
 
- }
 
 
  |