feat: deal attributes with select and options

This commit is contained in:
2025-10-29 19:37:27 +04:00
parent 0e8c9077c9
commit 82fcd6e8cb
14 changed files with 206 additions and 23 deletions

24
services/attr_select.py Normal file
View File

@ -0,0 +1,24 @@
from sqlalchemy.ext.asyncio import AsyncSession
from models import AttributeSelect
from repositories import AttrSelectRepository
from schemas.attr_select import (
AttrSelectSchema,
GetAllAttrSelectOptionsResponse,
AttrOptionSchema,
)
from services.mixins import ServiceGetAllMixin
class AttrSelectService(ServiceGetAllMixin[AttributeSelect, AttrSelectSchema]):
schema_class = AttrSelectSchema
def __init__(self, session: AsyncSession):
self.repository = AttrSelectRepository(session)
async def get_options(self, select_id: int) -> GetAllAttrSelectOptionsResponse:
options = await self.repository.get_options(select_id)
return GetAllAttrSelectOptionsResponse(
items=[AttrOptionSchema.model_validate(option) for option in options]
)