feat: barcode templates
This commit is contained in:
39
modules/fulfillment_base/services/barcode_template.py
Normal file
39
modules/fulfillment_base/services/barcode_template.py
Normal file
@ -0,0 +1,39 @@
|
||||
from modules.fulfillment_base.models import BarcodeTemplate
|
||||
from modules.fulfillment_base.repositories import BarcodeTemplateRepository
|
||||
from modules.fulfillment_base.schemas.barcode_template import *
|
||||
from services.mixins import *
|
||||
|
||||
|
||||
class BarcodeTemplateService(
|
||||
ServiceCrudMixin[
|
||||
BarcodeTemplate,
|
||||
BarcodeTemplateSchema,
|
||||
CreateBarcodeTemplateRequest,
|
||||
UpdateBarcodeTemplateRequest,
|
||||
]
|
||||
):
|
||||
schema_class = BarcodeTemplateSchema
|
||||
entity_deleted_msg = "Шаблон штрихкода успешно удален"
|
||||
entity_updated_msg = "Шаблон штрихкода успешно обновлен"
|
||||
entity_created_msg = "Шаблон штрихкода успешно создан"
|
||||
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.repository = BarcodeTemplateRepository(session)
|
||||
|
||||
async def is_soft_delete(self, template: BarcodeTemplate) -> bool:
|
||||
return True
|
||||
|
||||
async def get_attributes(self) -> GetBarcodeAttributesResponse:
|
||||
attributes = await self.repository.get_attributes()
|
||||
return GetBarcodeAttributesResponse(
|
||||
items=[
|
||||
BarcodeTemplateAttributeSchema.model_validate(attr)
|
||||
for attr in attributes
|
||||
]
|
||||
)
|
||||
|
||||
async def get_sizes(self) -> GetBarcodeTemplateSizesResponse:
|
||||
sizes = await self.repository.get_sizes()
|
||||
return GetBarcodeTemplateSizesResponse(
|
||||
items=[BarcodeTemplateSizeSchema.model_validate(size) for size in sizes]
|
||||
)
|
||||
Reference in New Issue
Block a user