Skip to content

feat: 어드민 여부#353

Merged
unifolio0 merged 1 commit into
developfrom
feat
Apr 20, 2026
Merged

feat: 어드민 여부#353
unifolio0 merged 1 commit into
developfrom
feat

Conversation

@unifolio0

Copy link
Copy Markdown
Contributor

closed #

작업 내용

스크린샷

참고 사항

@unifolio0 unifolio0 self-assigned this Apr 20, 2026
@unifolio0 unifolio0 merged commit 51e3b19 into develop Apr 20, 2026
1 of 2 checks passed
@unifolio0 unifolio0 deleted the feat branch April 20, 2026 14:13
@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd34264b-0418-4f23-9707-d0e60c75f908

📥 Commits

Reviewing files that changed from the base of the PR and between 55964f5 and 0014397.

📒 Files selected for processing (6)
  • src/main/java/com/samhap/kokomen/member/domain/Admin.java
  • src/main/java/com/samhap/kokomen/member/repository/AdminRepository.java
  • src/main/java/com/samhap/kokomen/member/service/MemberService.java
  • src/main/java/com/samhap/kokomen/member/service/dto/MyProfileResponse.java
  • src/main/resources/db/migration/V42__create_admin.sql
  • src/test/java/com/samhap/kokomen/member/controller/MemberControllerTest.java

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 관리자 기능이 추가되었습니다.
    • 사용자 프로필 응답에 관리자 여부 정보가 추가되었습니다.
  • 문서화

    • API 응답 문서가 업데이트되었습니다.

Walkthrough

테스트 사용자를 나타내는 하드코딩된 로직을 제거하고, 새로운 Admin JPA 엔티티와 저장소를 도입하여 어드민 상태를 데이터베이스에서 관리하는 방식으로 변경했습니다. 해당 서비스 레이어와 응답 DTO, 데이터베이스 스키마 및 테스트가 업데이트되었습니다.

Changes

Cohort / File(s) Summary
Admin 엔티티 및 저장소
src/main/java/com/samhap/kokomen/member/domain/Admin.java, src/main/java/com/samhap/kokomen/member/repository/AdminRepository.java
새로운 Admin JPA 엔티티와 JpaRepository를 상속한 AdminRepository 인터페이스 추가. existsByMemberId(Long memberId) 파생 쿼리 메서드 포함.
서비스 레이어 업데이트
src/main/java/com/samhap/kokomen/member/service/MemberService.java, src/main/java/com/samhap/kokomen/member/service/dto/MyProfileResponse.java
AdminRepository 의존성 추가 및 isTestUser 플래그를 isAdmin으로 변경. isAdmin 값은 개발/운영 프로필에서 특정 memberId에 대해 true이고, 그 외에는 저장소를 통해 조회.
데이터베이스 마이그레이션
src/main/resources/db/migration/V42__create_admin.sql
id (BIGINT, PRIMARY KEY, AUTO_INCREMENT)와 member_id (BIGINT, NOT NULL)를 포함하는 admin 테이블 생성. member 테이블과의 외래키 제약 추가.
테스트 업데이트
src/test/java/com/samhap/kokomen/member/controller/MemberControllerTest.java
응답 필드를 is_test_user에서 is_admin으로 변경. Spring REST Docs 문서화 업데이트.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MemberService
    participant AdminRepository
    participant Database

    Client->>MemberService: findMember(memberId)
    MemberService->>MemberService: 프로필 정보 조회
    
    alt Dev/Prod 프로필
        MemberService->>MemberService: 하드코딩된 ID로 isAdmin 결정
    else 기타 프로필
        MemberService->>AdminRepository: existsByMemberId(memberId)
        AdminRepository->>Database: SELECT COUNT(*) FROM admin WHERE member_id = ?
        Database-->>AdminRepository: 조회 결과
        AdminRepository-->>MemberService: isAdmin (boolean)
    end
    
    MemberService->>MemberService: MyProfileResponse 생성 (isAdmin 포함)
    MemberService-->>Client: MyProfileResponse 반환
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • nak-honest
  • kargowild

Poem

🐰 관리자 기능이 피어났네,
데이터베이스에서 반짝이네,
하드코딩 대신 저장소의 진실,
프로필 조회가 더욱 우아해졌네! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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은 기존의 하드코딩된 '테스트 사용자' 개념을 데이터베이스 기반의 '관리자' 역할로 전환하여 사용자 관리의 유연성과 확장성을 향상시킵니다. 새로운 Admin 엔티티와 리포지토리를 도입하고, MemberService 내에서 관리자 여부를 확인하는 로직을 업데이트하며, 관련 DTO와 데이터베이스 스키마를 변경합니다. 이를 통해 관리자 권한 부여 및 관리가 더욱 체계적으로 이루어질 수 있습니다.

Highlights

  • 새로운 Admin 엔티티 및 리포지토리 추가: 관리자 역할을 정의하는 Admin 엔티티와 이를 관리하기 위한 AdminRepository가 추가되었습니다.
  • 관리자 여부 확인 로직 개선: MemberService 내에서 기존의 하드코딩된 '테스트 사용자' 확인 로직이 AdminRepository를 활용하여 데이터베이스 기반의 '관리자' 확인 로직으로 변경되었습니다.
  • 프로필 응답 DTO 업데이트: MyProfileResponse DTO에서 isTestUser 필드가 isAdmin으로 변경되어 관리자 여부를 명확하게 나타내도록 수정되었습니다.
  • DB 마이그레이션 스크립트 추가: admin 테이블을 생성하는 새로운 SQL 마이그레이션 스크립트가 추가되어 데이터베이스 스키마가 업데이트되었습니다.
  • 테스트 코드 및 문서 업데이트: 관련 컨트롤러 테스트 코드와 API 문서가 is_test_user에서 is_admin으로 변경된 필드를 반영하도록 업데이트되었습니다.

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


관리자 권한, 데이터베이스에 담아, 새로운 시작.

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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an Admin entity and repository to manage administrative privileges, replacing the previous isTestUser logic. Changes include a new database migration, updates to the MemberService to check for admin status, and renaming fields in the MyProfileResponse DTO and associated tests. Feedback focuses on improving the isAdmin implementation by removing hardcoded member IDs in favor of the database-driven approach and optimizing performance by changing the fetch strategy of the Member relationship in the Admin entity from EAGER to LAZY.

Comment on lines +128 to 135
private boolean isAdmin(Long memberId) {
if ("dev".equals(activeProfile)) {
return memberId.equals(34L);
} else if ("prod".equals(activeProfile)) {
return memberId.equals(302L);
}
return false;
return adminRepository.existsByMemberId(memberId);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

devprod 환경에서 특정 memberId를 하드코딩하여 어드민 여부를 확인하고 있습니다. 이러한 방식은 유지보수가 어렵고, 새로 도입된 Admin 테이블의 데이터를 무시하게 됩니다. 예를 들어, dev 환경에서는 34번 사용자 외에 Admin 테이블에 등록된 다른 사용자가 어드민으로 인식되지 않습니다. 모든 환경에서 AdminRepository를 통해 일관되게 어드민 여부를 관리하도록 변경하는 것이 바람직합니다.

    private boolean isAdmin(Long memberId) {
        return adminRepository.existsByMemberId(memberId);
    }

@Id
private Long id;

@ManyToOne(fetch = FetchType.EAGER)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

@manytoone 관계의 기본 페치 전략은 EAGER입니다. 이는 불필요한 엔티티 로딩과 조인을 유발하여 성능 저하의 원인이 될 수 있으므로, 명시적으로 LAZY 전략을 사용하는 것을 권장합니다.

Suggested change
@ManyToOne(fetch = FetchType.EAGER)
@ManyToOne(fetch = FetchType.LAZY)

unifolio0 added a commit that referenced this pull request Jun 14, 2026
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