38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# app/repositories/mission_repository.py
|
|
"""
|
|
HealthSync AI 미션 데이터 리포지토리
|
|
"""
|
|
from typing import Dict, Any, Optional, List
|
|
from app.repositories.queries.mission_queries import MissionQueries
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class MissionRepository:
|
|
"""미션 데이터 DB 조회 리포지토리"""
|
|
|
|
@staticmethod
|
|
def _get_db():
|
|
"""simple_db를 lazy import로 가져오기 (순환 import 방지)"""
|
|
from app.utils.database_utils import simple_db
|
|
return simple_db
|
|
|
|
@staticmethod
|
|
async def get_mission_by_id(mission_id: int) -> Optional[Dict[str, Any]]:
|
|
"""미션 ID로 미션 정보 조회"""
|
|
try:
|
|
simple_db = MissionRepository._get_db()
|
|
result = await simple_db.execute_query(
|
|
MissionQueries.GET_USER_MISSION_BY_ID,
|
|
{"mission_id": mission_id}
|
|
)
|
|
|
|
if result and len(result) > 0:
|
|
logger.info(f"미션 정보 조회 성공 - mission_id: {mission_id}")
|
|
return result[0]
|
|
return None
|
|
|
|
except Exception as e:
|
|
logger.error(f"미션 정보 조회 실패 - mission_id: {mission_id}, error: {str(e)}")
|
|
raise Exception(f"미션 정보 조회 실패: {str(e)}") |