[STK1-06] 알림 API
작업 내용 (설계 의도)
변경 사항
AlertApiController — POST /api/v1/alerts(201), GET /api/v1/alerts, GET /api/v1/alerts/history, DELETE /api/v1/alerts/{id}(204).
- DTO 흐름: Request → Command → Response.
- presentation 레이어만 추가. 도메인 로직은 STK1-03의 DomainService에 위임.
의존
다이어그램
처리 흐름
sequenceDiagram
participant Client
participant CTL as AlertApiController
participant UC as CreatePriceAlertUseCase
participant DS as PriceAlertDomainService
Client->>CTL: POST /api/v1/alerts
CTL->>CTL: Request → Command
CTL->>UC: execute(command)
UC->>DS: createAlert(command)
DS-->>UC: PriceAlert
UC-->>CTL: CreateAlertResponse
CTL-->>Client: 201 Created
클래스 의존
flowchart LR
subgraph Presentation["presentation"]
CTL[AlertApiController]
end
subgraph Application["application"]
CUC[CreatePriceAlertUseCase]
GUC[GetActiveAlertsUseCase]
HUC[GetAlertHistoryUseCase]
DUC[DeleteAlertUseCase]
end
CTL --> CUC
CTL --> GUC
CTL --> HUC
CTL --> DUC
테스트 케이스
POST /api/v1/alerts 정상 요청 시 201과 생성된 알림 정보를 반환한다.
POST /api/v1/alerts 목표가에 음수를 전달하면 400을 반환한다.
GET /api/v1/alerts 알림이 없으면 200과 빈 배열을 반환한다.
GET /api/v1/alerts/history 이력이 여러 건이면 triggeredAt 내림차순으로 반환한다.
DELETE /api/v1/alerts/{id} 존재하는 ID이면 204를 반환한다.
DELETE /api/v1/alerts/{id} 존재하지 않는 ID이면 404를 반환한다.