This commit is contained in:
2024-04-12 07:34:21 +03:00
parent 5c81af05d5
commit be623a3555
12 changed files with 513 additions and 93 deletions

View File

@@ -75,7 +75,7 @@ class ClientService(BaseService):
try:
client = await self.get_by_name(request.data.name)
if client:
return ClientCreateResponse(ok=False, message='Client already exists')
return ClientCreateResponse(ok=False, message='Клиент с таким именем уже существует')
await self.create_client_raw(user, request.data.name, request.data.details)
await self.session.commit()
return ClientCreateResponse(ok=True, message='Client created')
@@ -86,11 +86,11 @@ class ClientService(BaseService):
try:
client = await self.get_by_id(request.data.id)
if not client:
return ClientUpdateResponse(ok=False, message='Client not found')
return ClientUpdateResponse(ok=False, message='Клиент не найден')
await self.session.execute(update(Client).where(Client.id == client.id).values(name=request.data.name))
await self.update_details(user, client, request.data.details)
await self.session.commit()
return ClientUpdateResponse(ok=True, message='Client updated')
return ClientUpdateResponse(ok=True, message='Клиент обновлен')
except Exception as e:
return ClientUpdateResponse(ok=False, message=str(e))
@@ -98,9 +98,9 @@ class ClientService(BaseService):
try:
client = await self.get_by_id(request.client_id)
if not client:
return ClientDeleteResponse(ok=False, message='Client not found')
return ClientDeleteResponse(ok=False, message='Клиент не найден')
await self.session.delete(client)
await self.session.commit()
return ClientDeleteResponse(ok=True, message='Client deleted')
return ClientDeleteResponse(ok=True, message='Клиент удален')
except Exception as e:
return ClientDeleteResponse(ok=False, message=str(e))