feat: patch and get statuses endpoints
This commit is contained in:
@ -1 +1,4 @@
|
||||
from .board import BoardService as BoardService
|
||||
from .deal import DealService as DealService
|
||||
from .project import ProjectService as ProjectService
|
||||
from .status import StatusService as StatusService
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from repositories.board import BoardRepository
|
||||
from repositories import BoardRepository
|
||||
from schemas.board import (
|
||||
GetBoardsResponse,
|
||||
BoardSchema,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from repositories.deal import DealRepository
|
||||
from repositories import DealRepository
|
||||
from schemas.deal import GetDealsResponse, DealSchema
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from repositories.project import ProjectRepository
|
||||
from repositories import ProjectRepository
|
||||
from schemas.project import GetProjectsResponse, ProjectSchema
|
||||
|
||||
|
||||
|
||||
25
services/status.py
Normal file
25
services/status.py
Normal 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="Статус успешно обновлен")
|
||||
Reference in New Issue
Block a user