From 9ab22b1a1c1e58602ed7321ad2e3253813e985e8 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Thu, 29 Oct 2020 08:13:20 +0800 Subject: [PATCH] =?UTF-8?q?update:=E7=A7=BB=E9=99=A4=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E4=B8=8E=E9=83=A8=E9=97=A8=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/permissions/controller/Role.php | 33 +++------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/catch/permissions/controller/Role.php b/catch/permissions/controller/Role.php index 6f74676..ebc2c52 100644 --- a/catch/permissions/controller/Role.php +++ b/catch/permissions/controller/Role.php @@ -9,12 +9,13 @@ use catcher\CatchResponse; use catcher\exceptions\FailedException; use catcher\Tree; use think\response\Json; +use catchAdmin\permissions\model\Roles as RoleModel; class Role extends CatchController { protected $role; - public function __construct(\catchAdmin\permissions\model\Roles $role) + public function __construct(RoleModel $role) { $this->role = $role; } @@ -22,7 +23,6 @@ class Role extends CatchController /** * * @time 2019年12月09日 - * @param Request $request * @return string */ public function index() @@ -50,9 +50,7 @@ class Role extends CatchController if (!empty($permissions)) { $this->role->attachPermissions(array_unique($permissions)); } - if (!empty($params['permissions'])) { - $this->role->attachDepartments($params['permissions']); - } + // 添加角色 return CatchResponse::success(); } @@ -61,7 +59,6 @@ class Role extends CatchController { $role = $this->role->findBy($id); $role->permissions = $role->getPermissions(); - $role->departments = $role->getDepartments(); return CatchResponse::success($role); } @@ -103,28 +100,6 @@ class Role extends CatchController if (!empty($attachIds)) { $role->attachPermissions(array_unique($attachIds)); } - - // 更新department - $hasDepartmentIds = $role->getDepartments()->column('id'); - $departmentIds = $request->param('departments',[]); - - // 已存在部门 IDS - $existedDepartmentIds = []; - foreach ($hasDepartmentIds as $hasDepartmentId) { - if (in_array($hasDepartmentId, $departmentIds)) { - $existedDepartmentIds[] = $hasDepartmentId; - } - } - - $attachDepartmentIds = array_diff($departmentIds, $existedDepartmentIds); - $detachDepartmentIds = array_diff($hasDepartmentIds, $existedDepartmentIds); - - if (!empty($detachDepartmentIds)) { - $role->detachDepartments($detachDepartmentIds); - } - if (!empty($attachDepartmentIds)) { - $role->attachDepartments(array_unique($attachDepartmentIds)); - } return CatchResponse::success(); } @@ -147,8 +122,6 @@ class Role extends CatchController $role = $this->role->findBy($id); // 删除权限 $role->detachPermissions(); - // 删除部门关联 - $role->detachDepartments(); // 删除用户关联 $role->users()->detach(); // 删除