23 lines
853 B
Python
23 lines
853 B
Python
from models import Status
|
|
from repositories import StatusRepository
|
|
from schemas.status import *
|
|
from services.mixins import *
|
|
|
|
|
|
class StatusService(
|
|
ServiceCrudMixin[Status, StatusSchema, CreateStatusRequest, UpdateStatusRequest]
|
|
):
|
|
schema_class = StatusSchema
|
|
entity_not_found_msg = "Статус не найден"
|
|
entity_deleted_msg = "Статус успешно удален"
|
|
entity_updated_msg = "Статус успешно обновлен"
|
|
entity_created_msg = "Статус успешно создан"
|
|
|
|
def __init__(self, session: AsyncSession):
|
|
self.repository = StatusRepository(session)
|
|
|
|
async def is_soft_delete(self, status: StatusSchema) -> bool:
|
|
deals_count = await self.repository.get_deals_count(status.id)
|
|
is_soft_needed: bool = deals_count > 0
|
|
return is_soft_needed
|