refactor: update repository mixin
This commit is contained in:
@ -8,6 +8,7 @@ from repositories.mixins import (
|
||||
RepCreateMixin,
|
||||
GetByIdMixin,
|
||||
GetAllMixin,
|
||||
RepUpdateMixin,
|
||||
)
|
||||
from schemas.board import UpdateBoardSchema, CreateBoardSchema
|
||||
|
||||
@ -17,6 +18,7 @@ class BoardRepository(
|
||||
GetAllMixin[Board],
|
||||
RepDeleteMixin[Board],
|
||||
RepCreateMixin[Board, CreateBoardSchema],
|
||||
RepUpdateMixin[Board, UpdateBoardSchema],
|
||||
GetByIdMixin[Board],
|
||||
):
|
||||
entity_class = Board
|
||||
@ -29,10 +31,4 @@ class BoardRepository(
|
||||
return stmt.options(selectinload(Board.deals))
|
||||
|
||||
async def update(self, board: Board, data: UpdateBoardSchema) -> Board:
|
||||
board.lexorank = data.lexorank if data.lexorank else board.lexorank
|
||||
board.name = data.name if data.name else board.name
|
||||
|
||||
self.session.add(board)
|
||||
await self.session.commit()
|
||||
await self.session.refresh(board)
|
||||
return board
|
||||
return await self._apply_update_data_to_model(board, data, True)
|
||||
|
||||
Reference in New Issue
Block a user