Files
Crm-Backend/repositories/board.py

21 lines
792 B
Python

from sqlalchemy.orm import selectinload
from models import Board
from repositories.mixins import *
from schemas.board import UpdateBoardSchema, CreateBoardSchema
class BoardRepository(RepCrudMixin[Board, CreateBoardSchema, UpdateBoardSchema]):
entity_class = Board
entity_not_found_msg = "Доска не найдена"
def _process_get_all_stmt_with_args(self, stmt: Select, *args) -> Select:
project_id = args[0]
return stmt.where(Board.project_id == project_id).order_by(Board.lexorank)
def _process_get_by_id_stmt(self, stmt: Select) -> Select:
return stmt.options(selectinload(Board.deals))
async def update(self, board: Board, data: UpdateBoardSchema) -> Board:
return await self._apply_update_data_to_model(board, data, True)