feat: modules and module-editor pages

This commit is contained in:
2025-10-25 12:11:48 +04:00
parent 62aeebf079
commit 281600c72d
16 changed files with 751 additions and 25 deletions

View File

@ -1,14 +1,14 @@
from fastapi import APIRouter
from fastapi import APIRouter, Path
from backend.dependecies import SessionDependency
from schemas.module import GetAllModulesResponse
from schemas.module import *
from services.module import ModuleService
router = APIRouter(tags=["modules"])
@router.get(
"/built-in/",
"/",
response_model=GetAllModulesResponse,
operation_id="get_modules",
)
@ -16,3 +16,76 @@ async def get_modules(
session: SessionDependency,
):
return await ModuleService(session).get_all()
@router.get(
"/with-attributes",
response_model=GetAllWithAttributesResponse,
operation_id="get_modules_with_attributes",
)
async def get_modules_with_attributes(
session: SessionDependency,
):
return await ModuleService(session).get_with_attributes()
@router.get(
"/{pk}/with-attributes",
response_model=GetByIdWithAttributesResponse,
operation_id="get_module_with_attributes",
)
async def get_module_with_attributes(
session: SessionDependency,
pk: int = Path(),
):
return await ModuleService(session).get_by_id_with_attributes(pk)
@router.patch(
"/{pk}/common-info",
response_model=UpdateModuleCommonInfoResponse,
operation_id="update_module",
)
async def update_module_common_info(
session: SessionDependency,
request: UpdateModuleCommonInfoRequest,
pk: int = Path(),
):
return await ModuleService(session).update(pk, request)
@router.delete(
"/{pk}",
response_model=DeleteModuleResponse,
operation_id="delete_module",
)
async def delete_module(
session: SessionDependency,
pk: int = Path(),
):
return await ModuleService(session).delete(pk)
@router.post(
"/attribute",
response_model=AddAttributeResponse,
operation_id="add_attribute_to_module",
)
async def add_attribute_to_module(
session: SessionDependency,
request: AddAttributeRequest,
):
return await ModuleService(session).add_attribute(request)
@router.delete(
"/attribute",
response_model=DeleteAttributeResponse,
operation_id="remove_attribute_from_module",
)
async def remove_attribute_from_module(
session: SessionDependency,
request: DeleteAttributeRequest,
):
return await ModuleService(session).delete_attribute(request)