from models import Attribute from repositories import AttributeRepository from schemas.attribute import * from services.mixins import * class AttributeService( ServiceCrudMixin[ Attribute, AttributeSchema, CreateAttributeRequest, UpdateAttributeRequest ] ): schema_class = AttributeSchema def __init__(self, session: AsyncSession): self.repository = AttributeRepository(session) async def update_attribute_label( self, request: UpdateAttributeLabelRequest ) -> UpdateAttributeLabelResponse: await self.repository.create_or_update_attribute_label( request.module_id, request.attribute_id, request.label ) return UpdateAttributeLabelResponse( message="Название атрибута в модуле изменено" ) async def get_attribute_types(self) -> GetAllAttributeTypesResponse: types = await self.repository.get_attribute_types() return GetAllAttributeTypesResponse( items=[AttributeTypeSchema.model_validate(t) for t in types] )