feat: attr options and selects editing
This commit is contained in:
56
routers/crm/v1/attr_option.py
Normal file
56
routers/crm/v1/attr_option.py
Normal file
@ -0,0 +1,56 @@
|
||||
from fastapi import APIRouter, Path
|
||||
|
||||
from backend.dependecies import SessionDependency
|
||||
from schemas.attr_option import *
|
||||
from services import AttrOptionService
|
||||
|
||||
router = APIRouter(tags=["attr_option"])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{selectId}",
|
||||
response_model=GetAllAttrSelectOptionsResponse,
|
||||
operation_id="get_attr_options",
|
||||
)
|
||||
async def get_attr_options(
|
||||
session: SessionDependency,
|
||||
select_id: int = Path(alias="selectId"),
|
||||
):
|
||||
return await AttrOptionService(session).get_all(select_id)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/",
|
||||
response_model=CreateAttrOptionResponse,
|
||||
operation_id="create_attr_option",
|
||||
)
|
||||
async def create_attr_select(
|
||||
session: SessionDependency,
|
||||
request: CreateAttrOptionRequest,
|
||||
):
|
||||
return await AttrOptionService(session).create(request)
|
||||
|
||||
|
||||
@router.patch(
|
||||
"/{pk}",
|
||||
response_model=UpdateAttrOptionResponse,
|
||||
operation_id="update_attr_option",
|
||||
)
|
||||
async def update_attr_option(
|
||||
session: SessionDependency,
|
||||
request: UpdateAttrOptionRequest,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await AttrOptionService(session).update(pk, request)
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/{pk}",
|
||||
response_model=DeleteAttrOptionResponse,
|
||||
operation_id="delete_attr_option",
|
||||
)
|
||||
async def delete_attr_option(
|
||||
session: SessionDependency,
|
||||
pk: int = Path(),
|
||||
):
|
||||
return await AttrOptionService(session).delete(pk)
|
||||
Reference in New Issue
Block a user