feat: setting parent for department section
This commit is contained in:
@@ -129,15 +129,17 @@ 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(
|
|
||||||
request.section.name,
|
|
||||||
department_id=request.section.department_id,
|
|
||||||
parent_section_id=request.section.parent_department_section_id,
|
|
||||||
)
|
|
||||||
if section_same_name:
|
|
||||||
return UpdateDepartmentSectionResponse(ok=False, message="Отдел с данным именем уже существует")
|
|
||||||
|
|
||||||
|
section_same_name = await self._get_section_by_name(
|
||||||
|
request.section.name,
|
||||||
|
department_id=request.section.department_id,
|
||||||
|
parent_section_id=request.section.parent_department_section_id,
|
||||||
|
)
|
||||||
|
if section_same_name:
|
||||||
|
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="Отдел успешно изменен")
|
||||||
|
|||||||
Reference in New Issue
Block a user