diff --git a/serverless.yml b/serverless.yml index ad28250..d987f51 100644 --- a/serverless.yml +++ b/serverless.yml @@ -182,11 +182,3 @@ functions: uri: ${file(envs/config.${self:provider.stage}.json):BILL_OCR_IMAGE_URI} timeout: 300 memorySize: 2048 - events: - - s3: - bucket: ${file(envs/config.${self:provider.stage}.json):BILL_BUCKET_NAME} - event: s3:ObjectCreated:Put - rules: - - prefix: "bills/" - existing: true - forceDeploy: true diff --git a/src/dto/bill_dto.py b/src/dto/bill_dto.py new file mode 100644 index 0000000..d8e291e --- /dev/null +++ b/src/dto/bill_dto.py @@ -0,0 +1,47 @@ +""" +관리비(Bill) 관련 DTO 클래스들을 정의합니다. +""" + +from typing import Optional, Any +from dataclasses import dataclass +from .base_dto import BaseDTO + + +@dataclass +class BillDTO(BaseDTO): + """단일 관리비 응답 DTO""" + + id: Optional[int] + studentNo: str + type: str + amount: Optional[float] + endDate: Optional[str] # YYYY-MM-DD + bankInfo: Optional[list[dict[str, Optional[str]]]] + + @classmethod + def from_supabase_data(cls, data: dict) -> "BillDTO": + """Supabase row(snake_case) -> DTO(camelCase) 매핑""" + return cls( + id=data.get("id"), + studentNo=data.get("student_no", ""), + type=data.get("type", ""), + amount=data.get("amount"), + endDate=( + str(data.get("end_date")) if data.get("end_date") is not None else None + ), + bankInfo=data.get("bank_info"), + ) + + +@dataclass +class BillListDTO(BaseDTO): + """관리비 목록 응답 DTO""" + + items: list[BillDTO] + + def to_dict(self) -> list[dict[str, Any]]: + return [item.to_dict() for item in self.items] + + @classmethod + def from_supabase_data(cls, rows: list[dict]) -> "BillListDTO": + return cls(items=[BillDTO.from_supabase_data(row) for row in rows])