Skip to content

🎨 Modify api endpoint#150

Merged
sotogito merged 3 commits intostgfrom
feat/member-info
Jan 16, 2026
Merged

🎨 Modify api endpoint#150
sotogito merged 3 commits intostgfrom
feat/member-info

Conversation

@sotogito
Copy link
Collaborator

✅ PR 타입

  • feat: 사용자 이름 반환 api 추가
    작업

🪾 반영 브랜치

feat/member-info -> stg

✨ 변경 사항

💯 테스트 결과

📂 관련 이슈

👀 리뷰어에게

@gemini-code-assist
Copy link

Summary of Changes

Hello @sotogito, 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!

이 풀 리퀘스트는 인증된 사용자가 자신의 닉네임을 조회할 수 있는 새로운 API 엔드포인트를 도입합니다. 이 개선 사항은 사용자 닉네임 정보에 직접 접근할 수 있는 방법을 제공하며, 적절한 인증 처리와 기능성을 보장하기 위한 견고한 단위 테스트가 뒷받침됩니다.

Highlights

  • 새로운 API 엔드포인트 추가: 인증된 사용자의 닉네임을 가져오는 GET 엔드포인트 /member/nickname이 추가되었습니다.
  • 인증 통합: 새로운 엔드포인트는 @AuthMember를 활용하여 인증된 컨텍스트에서 memberId를 추출합니다.
  • 단위 테스트 포함: 새로운 엔드포인트에 대한 포괄적인 단위 테스트가 추가되어, 인증된 사용자의 닉네임 조회 성공 및 비인가 접근 시나리오를 모두 다룹니다.

🧠 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.

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

안녕하세요. 사용자 닉네임을 반환하는 API 추가 작업을 리뷰했습니다.

전반적으로 코드가 잘 작성되었고, 관련 테스트 케이스도 꼼꼼하게 추가해주셨습니다. 한 가지 제안 사항은 API 응답 형식을 JSON 객체로 통일하는 것입니다. 현재 구현은 닉네임을 문자열(String)로 직접 반환하고 있는데, 이를 Map이나 별도의 DTO를 사용하여 JSON 형태로 반환하면 API의 일관성을 높이고 향후 확장에 더 유연하게 대처할 수 있습니다.

자세한 내용은 각 파일에 남긴 주석을 참고해주세요.

Comment on lines +30 to +37
@GetMapping("/member/nickname")
public ResponseEntity<String> getNickname(
@Parameter(hidden = true) @AuthMember final Long memberId
) {
final Member member = memberService.findMemberById(memberId);

return ResponseEntity.status(HttpStatus.OK).body(member.getNickname());
}

Choose a reason for hiding this comment

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

medium

API 응답으로 원시(raw) 문자열을 반환하는 것보다 JSON 객체를 반환하는 것이 좋습니다. 이는 API의 일관성을 유지하고 향후 확장을 용이하게 합니다. 예를 들어, 나중에 다른 필드를 추가해야 할 경우 클라이언트 코드 수정 없이 쉽게 확장할 수 있습니다.

Map.of()를 사용하거나 전용 응답 DTO(Data Transfer Object)를 생성하여 JSON 객체로 닉네임을 반환하도록 수정하는 것을 제안합니다. ResponseEntity.ok()를 사용하면 코드를 더 간결하게 만들 수 있습니다.

참고: 아래 제안을 적용하려면 import java.util.Map; 구문을 추가해야 합니다.

예시 DTO:

public record NicknameResponse(String nickname) {}
Suggested change
@GetMapping("/member/nickname")
public ResponseEntity<String> getNickname(
@Parameter(hidden = true) @AuthMember final Long memberId
) {
final Member member = memberService.findMemberById(memberId);
return ResponseEntity.status(HttpStatus.OK).body(member.getNickname());
}
@GetMapping("/member/nickname")
public ResponseEntity<Map<String, String>> getNickname(
@Parameter(hidden = true) @AuthMember final Long memberId
) {
final Member member = memberService.findMemberById(memberId);
return ResponseEntity.ok(Map.of("nickname", member.getNickname()));
}

Comment on lines +181 to +188
// then
final String responseContent = resultActions
.andExpect(status().isOk())
.andReturn()
.getResponse()
.getContentAsString(StandardCharsets.UTF_8);
assertThat(responseContent).isEqualTo(nickname);
verify(memberService).findMemberById(memberId);

Choose a reason for hiding this comment

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

medium

컨트롤러 변경 제안에 맞춰 테스트 코드도 수정이 필요합니다. getContentAsString()으로 응답 본문을 직접 비교하는 대신, jsonPath()를 사용하여 JSON 구조와 값을 검증하는 것이 더 안정적이고 가독성이 좋습니다. 다른 테스트에서도 jsonPath()를 사용하고 있으므로 일관성을 유지할 수 있습니다.

		// then
		resultActions.andExpect(status().isOk())
			.andExpect(jsonPath("$.nickname").value(nickname));
		verify(memberService).findMemberById(memberId);

@sonarqubecloud
Copy link

@sotogito sotogito merged commit cd4559d into stg Jan 16, 2026
8 checks 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.

2 participants

Comments