-
Notifications
You must be signed in to change notification settings - Fork 226
Open
Labels
Description
后端app/Service/Permission/DepartmentService.php 文件中的 updateById 方法存在缺陷:
bug描述:
当前的 updateById 方法只处理了部门的关联数据(部门用户和领导),但没有实际更新部门的基本信息(如部门名称)。这就是为什么后台提示修改成功,但数据库中部门名称没有变化的原因。
bug修复:
原代码在大约40-49行,修改为如下代码:
public function updateById(mixed $id, array $data): mixed
{
return Db::transaction(function () use ($id, $data) {
$entity = $this->repository->findById($id);
if (empty($entity)) {
throw new BusinessException(ResultCode::NOT_FOUND);
}
// 添加这一行来更新部门基本信息
$entity->fill($data)->save();
// 处理关联数据
$this->handleEntity($entity, $data);
return $entity;
});
}
Reactions are currently unavailable