feat: attr options and selects editing
This commit is contained in:
@ -7,3 +7,4 @@ from .deal_tag import DealTagRepository as DealTagRepository
|
||||
from .module import ModuleRepository as ModuleRepository
|
||||
from .project import ProjectRepository as ProjectRepository
|
||||
from .status import StatusRepository as StatusRepository
|
||||
from .attr_option import AttrOptionRepository as AttrOptionRepository
|
||||
|
||||
21
repositories/attr_option.py
Normal file
21
repositories/attr_option.py
Normal file
@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models import AttributeOption
|
||||
from repositories.mixins import RepCrudMixin
|
||||
from schemas.attr_option import CreateAttrOptionSchema, UpdateAttrOptionSchema
|
||||
|
||||
|
||||
class AttrOptionRepository(
|
||||
RepCrudMixin[AttributeOption, CreateAttrOptionSchema, UpdateAttrOptionSchema],
|
||||
):
|
||||
session: AsyncSession
|
||||
entity_class = AttributeOption
|
||||
entity_not_found_msg = "Опция не найдена"
|
||||
|
||||
def _process_get_all_stmt_with_args(self, stmt: Select, *args) -> Select:
|
||||
select_id = args[0]
|
||||
return stmt.where(
|
||||
AttributeOption.select_id == select_id,
|
||||
AttributeOption.is_deleted.is_(False),
|
||||
).order_by(AttributeOption.id)
|
||||
@ -1,19 +1,12 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models import AttributeSelect, AttributeOption
|
||||
from repositories.base import BaseRepository
|
||||
from repositories.mixins import RepGetAllMixin
|
||||
from models import AttributeSelect
|
||||
from repositories.mixins import RepCrudMixin
|
||||
from schemas.attr_select import UpdateAttrSelectSchema, CreateAttrSelectSchema
|
||||
|
||||
|
||||
class AttrSelectRepository(BaseRepository, RepGetAllMixin[AttributeSelect]):
|
||||
class AttrSelectRepository(
|
||||
RepCrudMixin[AttributeSelect, CreateAttrSelectSchema, UpdateAttrSelectSchema],
|
||||
):
|
||||
session: AsyncSession
|
||||
entity_class = AttributeSelect
|
||||
|
||||
async def get_options(self, select_id: int) -> list[AttributeOption]:
|
||||
stmt = select(AttributeOption).where(
|
||||
AttributeOption.select_id == select_id,
|
||||
AttributeOption.is_deleted.is_(False),
|
||||
)
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
Reference in New Issue
Block a user