feat: modules and module-editor pages
This commit is contained in:
78
routers/crm/v1/attribute.py
Normal file
78
routers/crm/v1/attribute.py
Normal file
@ -0,0 +1,78 @@
|
||||
from fastapi import APIRouter, Path
|
||||
|
||||
from backend.dependecies import SessionDependency
|
||||
from schemas.attribute import *
|
||||
from services import AttributeService
|
||||
|
||||
router = APIRouter(tags=["attribute"])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/",
|
||||
response_model=GetAllAttributesResponse,
|
||||
operation_id="get_attributes",
|
||||
)
|
||||
async def get_attributes(
|
||||
session: SessionDependency,
|
||||
):
|
||||
return await AttributeService(session).get_all()
|
||||
|
||||
|
||||
@router.post(
|
||||
"/",
|
||||
response_model=CreateAttributeResponse,
|
||||
operation_id="create_attribute",
|
||||
)
|
||||
async def create_attribute(
|
||||
session: SessionDependency,
|
||||
request: CreateAttributeRequest,
|
||||
):
|
||||
return await AttributeService(session).create(request)
|
||||
|
||||
|
||||
@router.patch(
|
||||
"/{pk}",
|
||||
response_model=UpdateAttributeResponse,
|
||||
operation_id="update_attribute",
|
||||
)
|
||||
async def update_attribute(
|
||||
session: SessionDependency,
|
||||
request: UpdateAttributeRequest,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await AttributeService(session).update(pk, request)
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/{pk}",
|
||||
response_model=DeleteAttributeResponse,
|
||||
operation_id="delete_attribute",
|
||||
)
|
||||
async def delete_attribute(
|
||||
session: SessionDependency,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await AttributeService(session).delete(pk)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/label",
|
||||
response_model=UpdateAttributeLabelResponse,
|
||||
operation_id="update_attribute_label",
|
||||
)
|
||||
async def update_attribute_label(
|
||||
session: SessionDependency,
|
||||
request: UpdateAttributeLabelRequest,
|
||||
):
|
||||
return await AttributeService(session).update_attribute_label(request)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/type",
|
||||
response_model=GetAllAttributeTypesResponse,
|
||||
operation_id="get_attribute_types",
|
||||
)
|
||||
async def get_attribute_types(
|
||||
session: SessionDependency,
|
||||
):
|
||||
return await AttributeService(session).get_attribute_types()
|
||||
Reference in New Issue
Block a user