fix: 공지 읽음 흐름 보완 및 시각·스키마 정합성 정리 - #145
Conversation
📝 WalkthroughWalkthrough최근 활동 응답 필드를 Changes알림 읽음 상태 및 공지 흐름
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ProjectNoticeController
participant ProjectNoticeService
participant ProjectNoticeReadRepository
Client->>ProjectNoticeController: GET project notice detail
ProjectNoticeController->>ProjectNoticeService: getProjectNotice(userId, projectId, noticeId)
ProjectNoticeService->>ProjectNoticeReadRepository: find user read status
ProjectNoticeReadRepository-->>ProjectNoticeService: read status
ProjectNoticeService-->>ProjectNoticeController: ProjectNoticeResponse
ProjectNoticeController-->>Client: ApiResponse<ProjectNoticeResponse>
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/test/java/com/slatto/domain/notification/service/ProjectNoticeActivityFlowIntegrationTest.java (1)
100-104: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win공지 작성자의 자동 읽음 상태를 테스트에 반영하세요.
Line 100의 다른 멤버
isRead=false검증은 올바릅니다. 그러나 공지 작성자의ProjectActivityRead레코드가 생성되므로 Line 104의isEmpty()는 테스트를 실패시킵니다. 작성자와 활동 ID를 검증하고, 작성자의 응답이isRead=true인지도 추가로 확인하세요.수정 예시
- assertThat(projectActivityReadRepository.findAll()).isEmpty(); + assertThat(projectActivityReadRepository.findAll()) + .singleElement() + .satisfies(read -> { + assertThat(read.getProjectMember().getUser().getId()).isEqualTo(chaTaehoon.getId()); + assertThat(read.getActivityLog().getId()).isEqualTo(activityLog.getId()); + }); + + ActivityLogListResponse authorResponse = recentActivityService.getRecentActivities( + project.getId(), chaTaehoon.getId(), null, 20 + ); + assertThat(authorResponse.items()).singleElement() + .extracting(ActivityLogListResponse.ActivityLogItem::isRead) + .isEqualTo(true);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/slatto/domain/notification/service/ProjectNoticeActivityFlowIntegrationTest.java` around lines 100 - 104, Update the assertions in ProjectNoticeActivityFlowIntegrationTest so the notice author’s automatically created ProjectActivityRead record is expected instead of asserting projectActivityReadRepository.findAll() is empty. Verify the record belongs to the author and the activity ID, and assert that the author’s read response is true while preserving the existing unread-member assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@src/test/java/com/slatto/domain/notification/service/ProjectNoticeActivityFlowIntegrationTest.java`:
- Around line 100-104: Update the assertions in
ProjectNoticeActivityFlowIntegrationTest so the notice author’s automatically
created ProjectActivityRead record is expected instead of asserting
projectActivityReadRepository.findAll() is empty. Verify the record belongs to
the author and the activity ID, and assert that the author’s read response is
true while preserving the existing unread-member assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a3416405-863c-4179-8dea-95506f0df6e1
📒 Files selected for processing (20)
src/main/java/com/slatto/domain/notification/controller/RecentActivityController.javasrc/main/java/com/slatto/domain/notification/dto/ActivityLogListResponse.javasrc/main/java/com/slatto/domain/notification/repository/NotificationSettingRepository.javasrc/main/java/com/slatto/domain/notification/repository/ProjectActivityReadCommandRepository.javasrc/main/java/com/slatto/domain/notification/service/NotificationSettingService.javasrc/main/java/com/slatto/domain/notification/service/RecentActivityService.javasrc/main/java/com/slatto/domain/project/controller/ProjectNoticeController.javasrc/main/java/com/slatto/domain/project/dto/ProjectNoticeResponse.javasrc/main/java/com/slatto/domain/project/repository/ProjectNoticeReadRepository.javasrc/main/java/com/slatto/domain/project/repository/ProjectPinRepository.javasrc/main/java/com/slatto/domain/project/service/ProjectNoticeService.javasrc/main/java/com/slatto/domain/project/service/ProjectService.javasrc/main/java/com/slatto/domain/recruitment/dto/RecruitmentDetailResponse.javasrc/main/java/com/slatto/domain/recruitment/dto/RecruitmentSummary.javasrc/main/java/com/slatto/domain/recruitment/repository/RecruitmentBookmarkRepository.javasrc/main/java/com/slatto/domain/recruitment/service/RecruitmentBookmarkService.javasrc/main/java/com/slatto/domain/video/repository/VideoBookmarkRepository.javasrc/test/java/com/slatto/domain/notification/controller/RecentActivityControllerIntegrationTest.javasrc/test/java/com/slatto/domain/notification/service/ProjectNoticeActivityFlowIntegrationTest.javasrc/test/java/com/slatto/domain/notification/service/RecentActivityServiceIntegrationTest.java
🔗 관련 이슈 (Related Issue)
📝 작업 내용
프론트 연동 과정에서 보고된 세 가지 문제를 정리했습니다.
Swagger 문서가 공지 작성자 응답에 실제로는 내려가지 않는 필드를 광고하고 있었고, 공지를 등록한 본인에게도 자기 공지가 안 읽음으로 표시됐으며, 최근활동 응답의 읽음 필드명이 홈 알림과 달라 혼동을 유발했습니다.
추가로 위 작업 중 일부 네이티브 쿼리가 DB 시계로 시각을 기록해 애플리케이션 시계와 어긋나는 문제를 함께 발견해 정리했습니다.
1. Swagger
WriterSummary스키마명 충돌springdoc은 OpenAPI 스키마 이름을 단순 클래스명으로 만듭니다. 아래 세 개의 중첩 클래스가 모두
WriterSummary라서 하나의 스키마로 합쳐졌습니다.ProjectNoticeResponse.WriterSummaryid,nicknameRecruitmentSummary.WriterSummaryid,nickname,profileImageUrlRecruitmentDetailResponse.WriterSummaryid,nickname,profileImageUrl,primaryRole,locations병합 결과 공지 API 문서에도
profileImageUrl,primaryRole,locations가 노출됐지만 실제 응답에는 없는 필드였습니다. 각 클래스에@Schema(name = ...)으로 고유 이름을 부여해 세 스키마를 분리했습니다.문서에서 사라진 필드일 뿐 응답 형태 변경은 없습니다.
2. 공지 상세 조회 추가
응답 형태는 목록 조회의
items[]한 건과 동일합니다.공지사항 목록 화면 자체는 목록 조회 응답만으로 구성할 수 있습니다. 이 엔드포인트는 최근활동과 알림이 내려주는
targetType,targetId로 특정 공지에 딥링크할 때 필요합니다. 목록이 커서 페이지네이션(기본 20, 최대 50)이라 오래된 공지는 목록 조회만으로 도달할 수 없기 때문입니다.읽음 처리(
PATCH .../read)와 합치지 않고 분리해 두었습니다. 합치면 상세를 열거나 새로고침할 때마다 쓰기가 발생하고 캐시도 걸 수 없습니다.3. 공지 작성자 자동 읽음 처리
공지 등록 시 작성자 본인의 읽음 레코드를 함께 생성하고, 등록 응답의
isRead를true로 내려줍니다. 자기가 쓴 공지에 안 읽음 표시가 남던 문제가 해소됩니다.방금 생성한 공지라 중복 행이 발생할 수 없어 upsert가 아닌 일반 저장을 사용합니다.
4. 네이티브 쿼리 시각을 애플리케이션 클럭으로 통일
프로젝트 대부분의 시각은 JPA Auditing, 즉 애플리케이션 시계로 기록됩니다. 그런데 일부 네이티브 upsert 쿼리만
NOW(6)/CURRENT_TIMESTAMP를 써서 MySQL 세션 타임존을 따랐고, 두 값이 9시간 어긋난 상태로 저장됐습니다.특히
project_notice_read.read_at은 이번 PR에서 추가한 작성자 자동 읽음(엔티티 저장, 애플리케이션 시계)과 기존 읽음 처리 API(네이티브 upsert, DB 시계)가 같은 컬럼에 서로 다른 시계로 쓰게 되는 구조였습니다.해당 쿼리 6개에서 DB 시계 사용을 제거하고 호출부가
LocalDateTime을 넘기도록 변경했습니다. 대상 테이블은project_notice_read,project_pin,project_activity_read,notification_setting,recruitment_bookmark,video_bookmark입니다.ProjectActivityReadCommandRepository는 H2와 MySQL용 SQL 상수를 따로 유지하는 구조라, 양쪽 모두 위치 파라미터 번호를 다시 매겼습니다.DB 파라미터 그룹의
time_zone은 변경하지 않았습니다. 기존에 저장된 값의 해석이 전부 바뀌기 때문입니다.이번 변경 이후 저장되는 값부터 정합성이 맞습니다. 이미 저장된 행의 보정은 이 PR 범위에 포함하지 않았습니다.
5. 최근활동 읽음 필드명 통일
홈 알림은 이미
isRead를 쓰고 있는데 최근활동만isNew를 써서 프론트에서 혼동이 있었습니다.isRead로 통일했습니다.이름만 바뀐 것이 아니라 값의 의미가 반대입니다. 프론트 배포와 순서를 맞춰야 합니다.
Swagger summary 문구도 홈 알림과 동일하게 맞췄습니다. 엔드포인트 경로 변경은 없습니다.
✅ PR 체크리스트
./gradlew compileJava,./gradlew test를 통과했습니다.Summary by CodeRabbit
새 기능
개선 사항
isNew에서isRead로 변경되어 의미가 명확해졌습니다.테스트