This commit is contained in:
JaguarJack
2020-09-07 19:57:58 +08:00
parent dd023caf36
commit 377b72ae19
3 changed files with 54 additions and 43 deletions

View File

@@ -5,6 +5,7 @@ use catcher\base\CatchController;
use catchAdmin\permissions\model\Department as DepartmentModel;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
use catcher\exceptions\FailedException;
use catcher\Tree;
class Department extends CatchController
@@ -63,6 +64,10 @@ class Department extends CatchController
*/
public function delete($id): \think\response\Json
{
if ($this->department->where('parent_id', $id)->find()) {
throw new FailedException('存在子部门,无法删除');
}
return CatchResponse::success($this->department->deleteBy($id));
}
}

View File

@@ -59,6 +59,7 @@ trait DataRangScopeTrait
case Roles::DEPARTMENT_DOWN_DATA:
// 查一下下级部门
$departmentIds = Department::where('parent_id', $user->department_id)->column('id');
$departmentIds[] = $user->department_id;
$userIds = array_merge([$user->id], $this->getUserIdsByDepartmentId($departmentIds));
break;
case Roles::DEPARTMENT_DATA: