feat: get boards endpoint
This commit is contained in:
6
repositories/base.py
Normal file
6
repositories/base.py
Normal file
@ -0,0 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
||||
class BaseRepository:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
16
repositories/board.py
Normal file
16
repositories/board.py
Normal file
@ -0,0 +1,16 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
from models import Board
|
||||
from repositories.base import BaseRepository
|
||||
|
||||
|
||||
class BoardRepository(BaseRepository):
|
||||
async def get_all(self, project_id: int) -> list[Board]:
|
||||
stmt = (
|
||||
select(Board)
|
||||
.where(Board.is_deleted.is_(False), Board.project_id == project_id)
|
||||
.options(selectinload(Board.statuses))
|
||||
)
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
@ -1,13 +1,10 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models.project import Project
|
||||
from repositories.base import BaseRepository
|
||||
|
||||
|
||||
class ProjectRepository:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
|
||||
class ProjectRepository(BaseRepository):
|
||||
async def get_all(self) -> list[Project]:
|
||||
stmt = select(Project).where(Project.is_deleted.is_(False))
|
||||
result = await self.session.execute(stmt)
|
||||
|
||||
Reference in New Issue
Block a user