"""
Law Interpretation Service - 법령해석 관련 비즈니스 로직
"""
import asyncio
from typing import Optional
from ..repositories.law_interpretation_repository import LawInterpretationRepository
from ..models import SearchLawInterpretationRequest, GetLawInterpretationRequest
class LawInterpretationService:
"""법령해석 관련 비즈니스 로직을 처리하는 Service"""
def __init__(self):
self.repository = LawInterpretationRepository()
async def search_law_interpretation(
self,
req: SearchLawInterpretationRequest,
arguments: Optional[dict] = None
) -> dict:
"""법령해석 검색"""
try:
if arguments is None:
arguments = {}
return await asyncio.to_thread(
self.repository.search_law_interpretation,
req.query,
req.page,
req.per_page,
req.agency,
arguments
)
except Exception as e:
return {
"error": f"법령해석 검색 중 오류 발생: {str(e)}",
"recovery_guide": "시스템 오류가 발생했습니다. 서버 로그를 확인하거나 관리자에게 문의하세요."
}
async def get_law_interpretation(
self,
req: GetLawInterpretationRequest,
arguments: Optional[dict] = None
) -> dict:
"""법령해석 조회"""
try:
if arguments is None:
arguments = {}
return await asyncio.to_thread(
self.repository.get_law_interpretation,
req.interpretation_id,
arguments
)
except Exception as e:
return {
"error": f"법령해석 조회 중 오류 발생: {str(e)}",
"recovery_guide": "시스템 오류가 발생했습니다. 서버 로그를 확인하거나 관리자에게 문의하세요."
}