perf: 优化团队部门支持3级部门

This commit is contained in:
kuaifan
2025-03-01 13:41:10 +08:00
parent cfd2e1fd7b
commit 36cdf87bfe
4 changed files with 97 additions and 35 deletions
+16 -3
View File
@@ -34,6 +34,21 @@ use App\Exceptions\ApiException;
*/
class UserDepartment extends AbstractModel
{
/**
* 获取所有父级部门
* @return array
*/
public function parents()
{
$parents = [];
$parent = $this;
while ($parent) {
$parents[] = $parent;
$parent = $parent->parent_id ? self::find($parent->parent_id) : null;
}
return $parents;
}
/**
* 保存部门
* @param $data
@@ -131,9 +146,7 @@ class UserDepartment extends AbstractModel
});
// 解散群组
$dialog = WebSocketDialog::find($this->dialog_id);
if ($dialog) {
$dialog->deleteDialog();
}
$dialog?->deleteDialog();
//
$this->delete();
}