feat: 이벤트 기반 알림 생성 로직 - #125
Merged
Merged
Conversation
…장격리, VIEWER접근, date파라미터)
…y' into feat/15-dashboard-recommendations
…OST /notifications/{id}/read) 추가
# Conflicts: # src/main/java/com/fowoco/server/dashboard/application/DashboardQueryService.java
This was referenced Aug 10, 2026
43 tasks
chaeliki
marked this pull request as ready for review
August 11, 2026 16:49
hywznn
reviewed
Aug 11, 2026
…REQUIRES_NEW) 적용
hywznn
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
왜 필요한가요?
Closes #15
PR #123 에 이어서, 실제 알림 생성 로직을 구현합니다.
완료된 범위
이벤트 기반 (4종)
ApprovalRequested 이벤트 발행 추가
DOCUMENT_SUBMITTED 처리 완료 후 WorkerResponseSubmitted 이벤트 발행
NEEDS_INFO 전이 시 TaskNeedsInfo 이벤트 발행
배치 기반 (1종)
전체 회사를 순회하며 7일 이내 마감인 열린 Task에 알림을 생성합니다.
결정 사항
또는 Task 생성자(createdBy) 본인에게 보내도록 했습니다.
미완료로 바뀌며 NEEDS_INFO가 되는 시점으로 해석했습니다.
update()(Task 핵심값 수정)에서도 같은 전이가 발생할 수 있는데,
체크리스트 쪽만 반영했습니다.
전체 회사를 대상으로 조회해야 하는데, 타 사업장 격리(RLS)를
지키려면 tenantDatabaseContext를 회사별로 설정하며 순회해야 해서,
전체 회사 ID 목록이 필요했습니다.
EventConsumption 기록·검사 메커니즘을 그대로 활용했습니다
(같은 이벤트가 같은 핸들러에 두 번 전달되지 않음).
다른 팀원 파일 수정 사항
생성자에 DomainEventPublisher(WorkerResponseService는
TaskRepository도 추가)를 주입했습니다.
event_publication, event_consumption을 추가했습니다. 이 PR에서
추가한 이벤트 발행 코드가 실행되며 이 테스트 시나리오에서 처음으로
event_publication 행이 쌓이게 됐고, 기존 정리 목록에 이 테이블이
없어 company 삭제 시 FK 위반이 발생하는 것을 확인해 수정했습니다.
InMemoryCompanyRepository(DemoAuthSeedRunnerTest,
DemoWorkerSeedRunnerTest)와 FakeTaskRepository
(DashboardQueryServiceTest)에 새 메서드 구현을 추가했습니다.
어떻게 검증했나요?
알림, KST 날짜 계산 경계값 검증)
1. 승인 요청 도착
{
"title": "승인 요청이 도착했습니다: 실제 알림 테스트용 업무",
"route": "/tasks/{taskId}",
"target_id": "{taskId}",
"read": false
}
read: true, unread_count: 0으로 정확히 반영됨을 확인했습니다.
멱등성을 확인했습니다..
2. 문서 보완 필요
미완료(completed: false)로 변경
{
"title": "문서 보완이 필요합니다: 실제 알림 테스트용 업무",
"route": "/tasks/{taskId}",
"target_id": "{taskId}",
"read": false
}
유지되고, 새 알림이 occurred_at 기준 최신순으로 앞에
추가됨을 확인했습니다.
3. 문서 제출 완료
approve)하여 task_status를 APPROVED로 전환
-> worker_link_token 발급
response_type: DOCUMENT_SUBMITTED 응답을 제출
{
"title": "문서 제출이 완료됐습니다: 실제 알림 테스트용 업무",
"route": "/tasks/{taskId}",
"target_id": "{taskId}",
"read": false
}
2건이 모두 정확히 쌓이고, unread_count도 2로 정확히
집계됨을 확인했습니다.
추가 개선 사항
DueSoonCompanyNotifier라는
별도 Service로 분리하고 @transactional(propagation = REQUIRES_NEW)를
적용했습니다.
이 수정이 실제로 문제를 해결하는지, Mock이 아닌 실제 Spring
컨텍스트·트랜잭션 환경에서 검증하기 위해
DueSoonNotificationSchedulerIntegrationTest(@SpringBootTest)를
추가했습니다. 스케줄러를 직접 호출한 뒤 실제 DB를 조회한 결과입니다:
=== DueSoonNotificationScheduler 실제 생성 결과 ===
title: 마감이 임박했습니다: 마감임박테스트업무
user_id (Task 생성자): 58000000-0000-0000-0000-000000000001
expected creator_id : 58000000-0000-0000-0000-000000000001