[BE-03] AlertRepositoryImpl (MySQL 이력 영속화)

작업 내용 (설계 의도)

변경 사항

AlertRepository(BE-01 interface)를 MySQL로 구현해 알림 이력을 영속화한다(FR-9). 근거 TDD: ../TDD.md §ERD·§시스템 역할 경계.

  • infrastructure/alerting/mysql/AlertJpaRepository.kt — Spring Data 기본 CRUD.
  • infrastructure/alerting/mysql/AlertRepositoryImpl.ktAlertRepository 구현, JPA 엔티티 ↔ 도메인 Alert 변환(reconstitute 사용). analysis@Type(JsonStringType)IncidentAnalysis data class 매핑(String blob 금지).
  • 복잡 쿼리 없음(save/findById) — @Query 미사용.

의존

  • BE-01 (AlertRepository interface, Alert·IncidentAnalysis)
  • DB-01 (alerts 테이블)

다이어그램

클래스 의존

flowchart LR
    Impl["AlertRepositoryImpl"] -.implements.-> Repo["AlertRepository (domain)"]
    Impl --> Jpa["AlertJpaRepository"]
    Jpa --> TBL["alerts"]

테스트 케이스

  • Alert를 저장하고 id로 조회하면 source·severity·env·status가 일치한다(TestContainers MySQL).
  • IncidentAnalysis(analysis JSON)가 저장·조회 왕복에서 필드 손실 없이 복원된다.
  • 존재하지 않는 id 조회 시 null을 반환한다.
  • ANALYZED 상태로 저장한 뒤 markDelivered 후 재저장하면 DELIVERED·delivered_at이 반영된다.