feat: attr options and selects editing
This commit is contained in:
@ -6,3 +6,4 @@ from .deal_group import DealGroupService as DealGroupService
|
||||
from .deal_tag import DealTagService as DealTagService
|
||||
from .project import ProjectService as ProjectService
|
||||
from .status import StatusService as StatusService
|
||||
from .attr_option import AttrOptionService as AttrOptionService
|
||||
|
||||
27
services/attr_option.py
Normal file
27
services/attr_option.py
Normal file
@ -0,0 +1,27 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from models import AttributeOption
|
||||
from repositories import AttrOptionRepository
|
||||
from schemas.attr_option import (
|
||||
AttrOptionSchema,
|
||||
CreateAttrOptionRequest,
|
||||
UpdateAttrOptionRequest,
|
||||
)
|
||||
from services.mixins import ServiceCrudMixin
|
||||
|
||||
|
||||
class AttrOptionService(
|
||||
ServiceCrudMixin[
|
||||
AttributeOption,
|
||||
AttrOptionSchema,
|
||||
CreateAttrOptionRequest,
|
||||
UpdateAttrOptionRequest,
|
||||
]
|
||||
):
|
||||
schema_class = AttrOptionSchema
|
||||
entity_deleted_msg = "Опция успешно удалена"
|
||||
entity_updated_msg = "Опция успешно обновлена"
|
||||
entity_created_msg = "Опция успешно создана"
|
||||
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.repository = AttrOptionRepository(session)
|
||||
@ -4,21 +4,21 @@ from models import AttributeSelect
|
||||
from repositories import AttrSelectRepository
|
||||
from schemas.attr_select import (
|
||||
AttrSelectSchema,
|
||||
GetAllAttrSelectOptionsResponse,
|
||||
AttrOptionSchema,
|
||||
CreateAttrSelectRequest,
|
||||
UpdateAttrSelectRequest,
|
||||
)
|
||||
from services.mixins import ServiceGetAllMixin
|
||||
from services.mixins import ServiceCrudMixin
|
||||
|
||||
|
||||
class AttrSelectService(ServiceGetAllMixin[AttributeSelect, AttrSelectSchema]):
|
||||
class AttrSelectService(
|
||||
ServiceCrudMixin[
|
||||
AttributeSelect,
|
||||
AttrSelectSchema,
|
||||
CreateAttrSelectRequest,
|
||||
UpdateAttrSelectRequest,
|
||||
]
|
||||
):
|
||||
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]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user