Skip to content

[feat] 작곡가 수정 API 추가#98

Merged
k3vin7 merged 1 commit intomainfrom
feat/updateComposer
Mar 3, 2026
Merged

[feat] 작곡가 수정 API 추가#98
k3vin7 merged 1 commit intomainfrom
feat/updateComposer

Conversation

@k3vin7
Copy link
Contributor

@k3vin7 k3vin7 commented Mar 3, 2026

Summary

  • PUT /composers/{composerId} 엔드포인트 추가 (204 No Content)
  • nativeName 제외 전 필드 필수
  • 어드민(id=5)만 호출 가능

@gemini-code-assist
Copy link

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은 기존 작곡가 정보를 업데이트하기 위한 새로운 API 엔드포인트를 도입합니다. 이를 통해 관리자는 작곡가 데이터의 정확성과 최신성을 유지할 수 있으며, 필수 필드 검증과 관리자 전용 접근 제한을 통해 데이터 무결성과 보안을 강화합니다. 전반적으로 작곡가 관리 기능의 확장과 안정성 향상에 기여합니다.

Highlights

  • 작곡가 수정 API 추가: PUT /composers/{composerId} 엔드포인트를 추가하여 특정 작곡가의 정보를 수정할 수 있도록 했습니다.
  • 필수 필드 검증: nativeName 필드를 제외한 모든 작곡가 정보 필드가 필수 입력 사항으로 지정되었습니다.
  • 관리자 접근 제한: 작곡가 수정 API는 관리자(ID가 5인 사용자)만 호출할 수 있도록 접근 권한이 제한되었습니다.
  • 엔티티 업데이트 로직: Composer 엔티티에 여러 필드를 한 번에 업데이트할 수 있는 update 메서드가 추가되었습니다.
  • 요청 DTO 정의: 작곡가 정보 수정을 위한 ComposerUpdateDto가 새로 정의되었습니다.

🧠 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/composer/application/ComposerService.java
    • ComposerUpdateDto를 임포트했습니다.
    • 작곡가 정보를 업데이트하는 updateComposer 메서드를 추가했습니다. 이 메서드는 관리자 권한을 확인하고 Composer 엔티티의 update 메서드를 호출합니다.
  • src/main/java/com/daramg/server/composer/domain/Composer.java
    • 작곡가 엔티티의 여러 필드를 한 번에 업데이트할 수 있는 update 메서드를 추가했습니다.
  • src/main/java/com/daramg/server/composer/dto/ComposerUpdateDto.kt
    • 작곡가 정보 업데이트 요청을 위한 ComposerUpdateDto 데이터 클래스를 새로 추가했습니다. 이 DTO는 nativeName을 제외한 모든 필드에 @NotBlank 또는 @NotNull 검증 어노테이션을 포함합니다.
  • src/main/java/com/daramg/server/composer/presentation/ComposerController.java
    • ComposerUpdateDto를 임포트했습니다.
    • PUT /composers/{composerId} 엔드포인트를 추가하여 작곡가 업데이트 기능을 제공했습니다. 이 엔드포인트는 ComposerServiceupdateComposer 메서드를 호출합니다.
  • src/test/java/com/daramg/server/composer/presentation/ComposerControllerTest.java
    • put 요청을 위한 MockMvcRequestBuilders를 임포트했습니다.
    • 작곡가 수정 API(PUT /composers/{composerId})의 동작을 검증하는 테스트 케이스를 추가했습니다. 이 테스트는 요청 본문, 경로 파라미터, 쿠키 및 응답 상태(204 No Content)를 확인합니다.
Activity
  • 이 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.

@k3vin7 k3vin7 merged commit 4c3dabe into main Mar 3, 2026
1 check passed
@k3vin7 k3vin7 deleted the feat/updateComposer branch March 3, 2026 12:18
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

This PR introduces the PUT /composers/{composerId} API to update composer information, with a generally well-implemented structure across controller, service, domain, DTO, and test code. However, a critical security concern has been identified: the application relies on a hardcoded user ID (5L) for administrative authorization. This practice is insecure and brittle, potentially leading to unauthorized access if the ID is reassigned or a regular user obtains it. Implementing a robust role-based access control (RBAC) system is strongly recommended. Additionally, to enhance maintainability and scalability, consider refactoring the service layer to use constants for the admin ID and extract duplicated authorization logic into a separate method. Also, the Composer entity's update method could benefit from a parameter object to reduce the number of arguments.

@Transactional
public void updateComposer(Long composerId, ComposerUpdateDto dto, User user) {
if (user.getId() != 5L) {
throw new BusinessException(CommonErrorStatus.FORBIDDEN);

Choose a reason for hiding this comment

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

security-high high

The use of a hardcoded user ID (5L) for administrative authorization is a significant security vulnerability. This is insecure as any user who happens to be assigned this ID could gain administrative privileges. This pattern is also present in other administrative methods like createComposer and deleteComposer. It is highly recommended to implement a robust role-based access control (RBAC) system by adding a role field to the User entity and checking for an ADMIN role instead of a specific user ID. Additionally, to improve maintainability and reduce duplication, this authorization logic should be extracted into a separate private method, as it is currently duplicated across createComposer, updateComposer, and deleteComposer.

Comment on lines +50 to +62
public void update(String koreanName, String englishName, String nativeName, Gender gender,
String nationality, Short birthYear, Short deathYear, String bio, Era era, Continent continent) {
this.koreanName = koreanName;
this.englishName = englishName;
this.nativeName = nativeName;
this.gender = gender;
this.nationality = nationality;
this.birthYear = birthYear;
this.deathYear = deathYear;
this.bio = bio;
this.era = era;
this.continent = continent;
}

Choose a reason for hiding this comment

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

medium

update 메서드가 10개의 파라미터를 받아 'Long Parameter List' 코드 스멜에 해당합니다. 파라미터가 많아지면 가독성이 떨어지고, 향후 필드 변경 시 실수를 유발할 수 있습니다.

이를 개선하기 위해 파라미터를 객체로 묶는 것을 고려해 보세요. 예를 들어, ComposerUpdateDto를 직접 전달하거나, 도메인 계층의 독립성을 유지하기 위해 별도의 ComposerUpdateParam 객체를 정의하여 사용할 수 있습니다.

예시 (별도 파라미터 객체 사용):

// In Composer.java
public void update(ComposerUpdateParam param) {
    this.koreanName = param.getKoreanName();
    this.englishName = param.getEnglishName();
    // ... etc
}

이렇게 하면 update 메서드의 시그니처가 간결해지고, 관련 데이터를 하나의 객체로 관리할 수 있어 코드의 응집도가 높아집니다.

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