feat: patch and get statuses endpoints

This commit is contained in:
2025-08-04 18:48:58 +04:00
parent 298e82d3d1
commit be1ea4009d
16 changed files with 146 additions and 15 deletions

25
services/status.py Normal file
View File

@ -0,0 +1,25 @@
from fastapi import HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from repositories import StatusRepository
from schemas.board import UpdateBoardResponse
from schemas.status import UpdateStatusRequest, GetStatusesResponse, StatusSchema
class StatusService:
def __init__(self, session: AsyncSession):
self.repository = StatusRepository(session)
async def get_statuses(self, board_id: int) -> GetStatusesResponse:
statuses = await self.repository.get_all(board_id)
return GetStatusesResponse(
statuses=[StatusSchema.model_validate(status) for status in statuses]
)
async def update_status(self, status_id: int, request: UpdateStatusRequest):
status = await self.repository.get_by_id(status_id)
if not status:
raise HTTPException(status_code=404, detail="Статус не найден")
await self.repository.update(status, request.status)
return UpdateBoardResponse(message="Статус успешно обновлен")