Skip to content

Comments

[fix] 공지사항 상세조회 500 에러 수정#81

Merged
k3vin7 merged 1 commit intomainfrom
feat/notification
Feb 17, 2026
Merged

[fix] 공지사항 상세조회 500 에러 수정#81
k3vin7 merged 1 commit intomainfrom
feat/notification

Conversation

@k3vin7
Copy link
Contributor

@k3vin7 k3vin7 commented Feb 17, 2026

Summary

  • GET /notice/** 경로에 permitAll 추가하여 비로그인 사용자도 공지사항 조회 가능
  • 상세조회 로직을 서비스 레이어로 이동하여 LAZY 로딩 문제(LazyInitializationException) 해결

Test plan

  • 전체 테스트 통과 확인
  • 비로그인 상태에서 공지사항 상세조회 정상 동작 확인

🤖 Generated with Claude Code

- GET /notice/** permitAll 추가
- 상세조회를 서비스 레이어로 이동하여 LAZY 로딩 문제 해결

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @k3vin7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 공지사항 상세 조회 시 발생할 수 있는 500 에러를 해결하고 사용자 접근성을 개선합니다. 비로그인 사용자도 공지사항을 조회할 수 있도록 보안 설정을 완화하고, 상세 조회 로직을 서비스 계층으로 옮겨 지연 로딩 관련 문제를 방지합니다. 이를 통해 시스템의 안정성과 사용 편의성이 향상됩니다.

Highlights

  • 비로그인 사용자 공지사항 상세 조회 허용: SecurityConfig에서 /notice/** 경로에 대한 GET 요청에 permitAll을 추가하여 인증되지 않은 사용자도 공지사항을 조회할 수 있도록 했습니다.
  • 공지사항 상세 조회 로직 서비스 계층 이동: LazyInitializationException 발생 가능성을 해결하기 위해 공지사항 상세 조회 로직을 NoticeQueryController에서 NoticeQueryService로 이동시켰습니다.
  • 테스트 코드 리팩토링: 변경된 로직에 맞춰 NoticeQueryControllerTest의 상세 조회 테스트 케이스를 업데이트했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/java/com/daramg/server/auth/config/SecurityConfig.java
    • GET /notice/** 경로에 permitAll()을 추가하여 비로그인 사용자 접근을 허용했습니다.
  • src/main/java/com/daramg/server/notice/application/NoticeQueryService.java
    • NoticeDetailResponse를 임포트했습니다.
    • EntityUtils 의존성을 추가했습니다.
    • getNoticeDetail 메서드를 추가하여 공지사항 상세 조회 로직을 구현했습니다.
  • src/main/java/com/daramg/server/notice/presentation/NoticeQueryController.java
    • EntityUtils 및 Notice 임포트를 제거했습니다.
    • EntityUtils 필드 주입을 제거했습니다.
    • getNoticeDetail 메서드가 NoticeQueryService로 상세 조회 로직을 위임하도록 변경했습니다.
  • src/test/java/com/daramg/server/notice/presentation/NoticeQueryControllerTest.java
    • EntityUtils, Notice, User 임포트를 제거하고 NoticeDetailResponse 임포트를 추가했습니다.
    • Mockito.mock 임포트를 제거했습니다.
    • EntityUtils 목킹을 제거했습니다.
    • 공지사항_상세조회를_조회한다 테스트에서 NoticeQueryService의 getNoticeDetail 메서드를 목킹하도록 수정했습니다.
Activity
  • 작성자가 PR 생성 시 500 에러 수정 및 비로그인 사용자 공지사항 조회 허용이라는 명확한 목표를 제시했습니다.
  • 작성자가 테스트 계획에 전체 테스트 통과 확인과 비로그인 상태에서의 공지사항 상세 조회 동작 확인을 포함했습니다.
  • 작성자가 Claude Code를 사용하여 PR을 생성했음을 명시했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 공지사항 상세 조회 시 발생하던 500 에러를 수정하고, 비로그인 사용자도 공지사항을 조회할 수 있도록 접근 권한을 변경하는 것을 목표로 합니다. 상세 조회 로직을 컨트롤러에서 서비스 계층으로 이동하여 트랜잭션 내에서 지연 로딩된 연관 엔티티에 접근하도록 변경함으로써 LazyInitializationException 문제를 해결한 점이 좋습니다. 또한, 테스트 코드도 이러한 변경에 맞게 잘 수정되었습니다.

리뷰에서는 테스트 코드의 재현성을 높이기 위한 개선점과, 공지사항 상세 조회 시 발생할 수 있는 N+1 쿼리 문제에 대한 성능 개선 방안을 제안했습니다. 전반적으로 PR의 목적을 잘 달성했으며, 코드 구조도 개선되었습니다.

}

public NoticeDetailResponse getNoticeDetail(Long noticeId) {
Notice notice = entityUtils.getEntity(noticeId, Notice.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 구현은 Notice 엔티티를 조회한 후, NoticeDetailResponse로 변환하는 과정에서 notice.getUser()를 접근할 때 지연 로딩으로 인해 추가적인 쿼리가 발생할 수 있습니다. 이는 N+1 문제로 이어질 수 있습니다. Notice를 조회할 때 fetch join을 사용하여 연관된 User 엔티티를 함께 가져오는 것이 성능상 더 효율적입니다.

NoticeQueryRepositoryfetch join을 사용하는 새로운 조회 메서드(예: findByIdWithUser)를 추가하고, entityUtils.getEntity() 대신 해당 메서드를 사용하도록 수정하는 것을 고려해보세요.

Comment on lines +95 to +99
NoticeDetailResponse response = new NoticeDetailResponse(
1L, "관리자", "https://example.com/profile.jpg",
"공지사항 제목", "공지사항 상세 내용입니다.",
List.of("https://example.com/image1.jpg"), LocalDateTime.now()
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

테스트의 재현성을 보장하기 위해 LocalDateTime.now() 대신 고정된 시간 값을 사용하는 것이 좋습니다. 이렇게 하면 테스트 실행 시점과 관계없이 항상 동일한 응답을 기대할 수 있어 테스트 안정성이 향상됩니다.

Suggested change
NoticeDetailResponse response = new NoticeDetailResponse(
1L, "관리자", "https://example.com/profile.jpg",
"공지사항 제목", "공지사항 상세 내용입니다.",
List.of("https://example.com/image1.jpg"), LocalDateTime.now()
);
NoticeDetailResponse response = new NoticeDetailResponse(
1L, "관리자", "https://example.com/profile.jpg",
"공지사항 제목", "공지사항 상세 내용입니다.",
List.of("https://example.com/image1.jpg"), LocalDateTime.of(2024, 1, 1, 12, 0, 0)
);

@k3vin7 k3vin7 merged commit 85777e5 into main Feb 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant