✨ Feat: [#64] 모델 객체, 시리얼라이저 매핑 서비스 로직 구현
This commit is contained in:
29
nocodetools/services.py
Normal file
29
nocodetools/services.py
Normal 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)
|
||||||
Reference in New Issue
Block a user