feat: setting parent for department section

This commit is contained in:
2025-01-24 15:18:17 +04:00
parent 7e301ea5ce
commit 8857da1063

View File

@@ -129,7 +129,7 @@ class DepartmentService(BaseService):
section = await self._get_section_by_id(request.section.id) section = await self._get_section_by_id(request.section.id)
if not section: if not section:
return UpdateDepartmentSectionResponse(ok=False, message=f"Отдел с ID {request.section.id} не найден") return UpdateDepartmentSectionResponse(ok=False, message=f"Отдел с ID {request.section.id} не найден")
if section.name != request.section.name:
section_same_name = await self._get_section_by_name( section_same_name = await self._get_section_by_name(
request.section.name, request.section.name,
department_id=request.section.department_id, department_id=request.section.department_id,
@@ -138,6 +138,8 @@ class DepartmentService(BaseService):
if section_same_name: if section_same_name:
return UpdateDepartmentSectionResponse(ok=False, message="Отдел с данным именем уже существует") return UpdateDepartmentSectionResponse(ok=False, message="Отдел с данным именем уже существует")
section.parent_department_section_id = request.section.parent_department_section_id
section.department_id = request.section.department_id
section.name = request.section.name section.name = request.section.name
await self.session.commit() await self.session.commit()
return UpdateDepartmentSectionResponse(ok=True, message="Отдел успешно изменен") return UpdateDepartmentSectionResponse(ok=True, message="Отдел успешно изменен")