Feat: [#64] 모델 객체, 시리얼라이저 매핑 서비스 로직 구현

This commit is contained in:
sm4640
2025-06-05 18:33:01 +09:00
parent d164279ef0
commit 6321c1bf34

29
nocodetools/services.py Normal file
View File

@@ -0,0 +1,29 @@
from .models import *
from .serializers import *
from projects.models import Project
from portfolios.models import Portfolio
from projects.serializers import ProjectNocodetoolSerializer
from portfolios.serializers import PortfolioNocodetoolSerializer
NOCODETOOL_MODEL_MAP = {
'project': Project,
'portfolio': Portfolio,
}
NOCODETOOL_SERIALIZER_MAP = {
'project': ProjectNocodetoolSerializer,
'portfolio': PortfolioNocodetoolSerializer,
}
class NocodetoolObjectMapService:
@staticmethod
def mapping_model_instance(related_type: str, related_id: str):
object_model = NOCODETOOL_MODEL_MAP.get(related_type)
if not object_model:
return None
return object_model.objects.filter(id=related_id).first()
def mapping_model_serializer(related_type: str):
return NOCODETOOL_SERIALIZER_MAP.get(related_type, None)