Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/#218 club 이미지 추가 #219

Merged
merged 7 commits into from
Mar 11, 2025
Merged

Conversation

minjo-on
Copy link
Contributor

Summary

club 이미지 추가

Tasks

  • Club Entity 파일 컬럼 추가
  • Club Response FilePath 추가
  • Club file 등록 api 추가
  • 테스트 코드 수정
  • sql schema 수정

Screenshot

image

@minjo-on minjo-on added the 🔨refactor refactoring code label Mar 11, 2025
@minjo-on minjo-on requested a review from a team March 11, 2025 06:59
@minjo-on minjo-on self-assigned this Mar 11, 2025
@minjo-on minjo-on linked an issue Mar 11, 2025 that may be closed by this pull request
2 tasks
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

이번 PR은 동아리 생성 기능에 파일 연관 기능을 추가하는 변경 사항입니다. 주요 변경으로는 동아리 생성 메서드에 fileId(또는 추가 파라미터)를 추가하여 클럽과 파일 간 연관을 처리하도록 수정되었으며, 이에 따라 서비스, 도메인 객체, 컨트롤러, 테스트 및 데이터베이스 스키마와 SQL 스크립트가 업데이트되었습니다.

Changes

File(s) Change Summary
aics-admin/.../ClubAdminFacade.java, aics-admin/.../ClubAdminController.java, aics-admin/.../ClubAdminControllerImpl.java, aics-admin/.../ClubAdminFacadeTest.java createClub 메서드 시그니처에 fileId 파라미터 추가 및 관련 서비스 호출 수정
aics-domain/.../ClubCommandService.java, aics-domain/.../Club.java, aics-domain/.../FakeTestContainer.java, aics-domain/.../TestContainer.java, aics-domain/.../ClubCommandServiceTest.java, aics-domain/.../ClubQueryServiceTest.java, aics-domain/.../ClubDomainTest.java createClubClub.create 메서드에 추가 파라미터 도입, FileQueryService 주입 및 테스트 코드 업데이트
aics-admin/.../FileAdminController.java, aics-admin/.../FileAdminControllerImpl.java, aics-domain/.../FileDomain.java 동아리 로고 이미지를 위한 업로드 메서드 추가 및 파일 도메인(enum)에 CLUB 상수 추가
aics-api/.../ClubDetailResponse.java 응답 객체에 파일 정보를 나타내는 file 필드 추가 및 매핑 로직 업데이트
aics-api/.../data.sql, aics-api/.../schema.sql club 테이블에 file_id 컬럼 추가, 기존 데이터 삽입문 수정 및 file_entity 테이블에 동아리 로고 관련 데이터 추가

Possibly related PRs

Suggested labels

✨feature

Suggested reviewers

  • LeeHanEum

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 11, 2025

Test Coverage Report

Overall Project 94.52% -0.32% 🍏
Files changed 81.48% 🍏

Module Coverage
aics-admin 98% 🍏
aics-domain 92.24% -0.48%
Files
Module File Coverage
aics-admin ClubAdminFacade.java 100% 🍏
aics-domain Club.java 100% 🍏
ClubCommandService.java 86.11% -13.89%

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...n/club/application/command/ClubCommandService.java 50.00% 1 Missing and 1 partial ⚠️

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #219      +/-   ##
=============================================
- Coverage      92.23%   91.82%   -0.41%     
  Complexity       148      148              
=============================================
  Files             49       49              
  Lines            412      416       +4     
  Branches           4        5       +1     
=============================================
+ Hits             380      382       +2     
- Misses            27       28       +1     
- Partials           5        6       +1     
Files with missing lines Coverage Δ Complexity Δ
...lopers/admin/club/application/ClubAdminFacade.java 100.00% <100.00%> (ø) 3.00 <1.00> (ø)
...n/java/kgu/developers/domain/club/domain/Club.java 100.00% <100.00%> (ø) 4.00 <0.00> (ø)
...n/club/application/command/ClubCommandService.java 81.81% <50.00%> (-18.19%) 3.00 <1.00> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3997906...d7cf502. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
aics-api/src/main/java/kgu/developers/api/club/presentation/response/ClubDetailResponse.java (1)

22-25: Swagger 문서 예제 개선 필요

file 필드에 대한 Swagger 문서가 추가되었습니다. 그러나 예제 값인 "/cloud/file/3/2025-curriculum"은 동아리 이미지보다는 교육과정과 관련된 것처럼 보입니다. 동아리 이미지에 맞는 더 적절한 예제를 사용하는 것이 좋겠습니다.

@Schema(description = "첨부 파일 정보",
-	example = "{\"physicalPath\": \"/cloud/file/3/2025-curriculum\"}",
+	example = "{\"physicalPath\": \"/cloud/file/3/club-logo\"}",
	requiredMode = NOT_REQUIRED)
FilePathResponse file
aics-domain/src/testFixtures/java/club/application/ClubQueryServiceTest.java (1)

53-53: 테스트 내용 업데이트 필요

Club 클래스에 file 필드가 추가되었으므로, 테스트 검증부(then 부분)에서 파일 필드의 null 상태도 함께 검증하는 것이 좋을 것 같습니다.

// then
assertEquals("Club a", result.getName());
assertEquals("a 동아리입니다.", result.getDescription());
assertEquals("http://club-a.kyonggi.ac.kr", result.getSite());
+assertEquals(null, result.getFile());
aics-domain/src/testFixtures/java/club/domain/ClubDomainTest.java (1)

25-35: 파일 연관성 테스트 케이스 추가 필요

현재는 null을 전달하는 테스트만 있습니다. 실제 FileEntity가 있는 경우의 테스트 케이스도 추가하면 코드 커버리지가 향상될 것입니다.

파일 엔티티를 전달하는 테스트 케이스를 추가하는 것이 좋겠습니다:

@Test
@DisplayName("Club 객체를 파일과 함께 생성할 수 있다")
public void createClubWithFile_Success() {
    // given
    FileEntity mockFile = mock(FileEntity.class);
    
    // when
    Club newClub = Club.create(NAME, DESCRIPTION, SITE, mockFile);
    
    // then
    assertNotNull(newClub);
    assertEquals(NAME, newClub.getName());
    assertEquals(DESCRIPTION, newClub.getDescription());
    assertEquals(SITE, newClub.getSite());
    assertEquals(mockFile, newClub.getFile());
}
aics-admin/src/main/java/kgu/developers/admin/file/presentation/FileAdminControllerImpl.java (1)

66-73: 파일 유효성 검사 고려 필요

현재 구현에는 파일 유효성 검사가 없습니다. 이미지 파일만 허용하거나 특정 크기로 제한하는 등의 유효성 검사를 추가하는 것이 좋을 것 같습니다.

파일 유효성 검사 로직을 추가하는 것을 고려해보세요:

@Override
@PostMapping(value = "/club", consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<FilePathResponse> clubFileUpload(
    @RequestPart(value = "file") MultipartFile file
) {
    // 파일 유효성 검사
    if (file.isEmpty()) {
        throw new IllegalArgumentException("파일이 비어 있습니다");
    }
    
    // 이미지 파일 형식 검사
    String contentType = file.getContentType();
    if (contentType == null || !contentType.startsWith("image/")) {
        throw new IllegalArgumentException("이미지 파일만 업로드 가능합니다");
    }
    
    FilePathResponse path = fileAdminFacade.saveFile(file, CLUB);
    return ResponseEntity.status(CREATED).body(path);
}
aics-admin/src/testFixtures/java/club/application/ClubAdminFacadeTest.java (1)

54-58: 파일 연결에 대한 테스트 검증이 부족합니다.

테스트가 동아리 생성은 확인하지만, 생성된 동아리에 파일이 실제로 연결되었는지 검증하는 로직이 누락되었습니다. 파일 연결이 제대로 이루어졌는지 확인하는 assertion을 추가하는 것이 좋겠습니다.

다음과 같이 파일 연결을 검증하는 assertion을 추가해보세요:

 // then
 assertEquals(2, resultData.size());
 assertEquals(2L, result.id());
+Club savedClub = fakeClubRepository.findById(2L).get();
+assertEquals(fileId, savedClub.getFile() != null ? savedClub.getFile().getId() : null);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3997906 and 2ee8d2e.

📒 Files selected for processing (18)
  • aics-admin/src/main/java/kgu/developers/admin/club/application/ClubAdminFacade.java (1 hunks)
  • aics-admin/src/testFixtures/java/club/application/ClubAdminFacadeTest.java (2 hunks)
  • aics-domain/src/main/java/kgu/developers/domain/club/application/command/ClubCommandService.java (1 hunks)
  • aics-domain/src/main/java/kgu/developers/domain/club/domain/Club.java (2 hunks)
  • aics-domain/src/testFixtures/java/mock/FakeTestContainer.java (2 hunks)
  • aics-domain/src/testFixtures/java/mock/TestContainer.java (1 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminController.java (2 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminControllerImpl.java (2 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/file/presentation/FileAdminController.java (2 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/file/presentation/FileAdminControllerImpl.java (3 hunks)
  • aics-domain/src/main/java/kgu/developers/domain/file/domain/FileDomain.java (1 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminControllerImpl.java (1 hunks)
  • aics-api/src/main/java/kgu/developers/api/club/presentation/response/ClubDetailResponse.java (2 hunks)
  • aics-domain/src/testFixtures/java/club/application/ClubCommandServiceTest.java (3 hunks)
  • aics-domain/src/testFixtures/java/club/application/ClubQueryServiceTest.java (1 hunks)
  • aics-domain/src/testFixtures/java/club/domain/ClubDomainTest.java (1 hunks)
  • aics-api/src/main/resources/db/data.sql (2 hunks)
  • aics-api/src/main/resources/db/schema.sql (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
aics-domain/src/main/java/kgu/developers/domain/club/application/command/ClubCommandService.java

[warning] 22-22: aics-domain/src/main/java/kgu/developers/domain/club/application/command/ClubCommandService.java#L22
Added line #L22 was not covered by tests

🔇 Additional comments (30)
aics-domain/src/main/java/kgu/developers/domain/file/domain/FileDomain.java (1)

13-13: 변경사항이 적절합니다

CLUB 항목을 FileDomain 열거형에 추가한 것은 요구사항에 잘 부합합니다. 기존 패턴을 따라 올바르게 구현되었습니다.

aics-api/src/main/java/kgu/developers/api/club/presentation/response/ClubDetailResponse.java (3)

8-8: 적절한 import 추가

필요한 FilePathResponse 클래스를 정확히 import 했습니다.


20-21: 문법적 수정 적절함

코드 구조를 유지하기 위해 필요한 문법적 변경(콤마 추가)이 적절하게 이루어졌습니다.


32-33: null 처리가 잘 구현됨

Club 객체에서 파일이 존재하지 않는 경우(null)에 대한 처리가 적절하게 구현되었습니다.

aics-domain/src/testFixtures/java/club/application/ClubQueryServiceTest.java (2)

24-24: 테스트 코드 업데이트 적절함

Club.create 메소드 호출을 변경된 시그니처에 맞게 업데이트했습니다. 현재는 파일을 사용하지 않는 테스트이므로 null을 전달하는 것이 적절합니다.


28-28: 테스트 코드 업데이트 적절함

두 번째 Club.create 메소드 호출도 시그니처 변경에 맞게 적절히 업데이트되었습니다.

aics-domain/src/testFixtures/java/mock/TestContainer.java (1)

126-130: 클럽 관련 서비스 초기화 리팩터링

clubRepository, clubQueryServiceclubCommandService의 초기화가 이제 파일 후반부로 이동되었고, clubCommandService는 이제 fileQueryService를 의존성으로 추가했습니다. 이는 클럽 이미지 기능 추가에 필요한 변경 사항으로 보입니다.

aics-admin/src/main/java/kgu/developers/admin/club/application/ClubAdminFacade.java (1)

20-21: 클럽 생성 메서드에 파일 연관 기능 추가

클럽 생성 메서드에 fileId 매개변수가 추가되어 이미지를 클럽에 연결할 수 있게 되었습니다. 이는 PR 목표에 맞게 클럽 엔티티에 이미지 기능을 추가하는 변경입니다.

aics-domain/src/testFixtures/java/club/domain/ClubDomainTest.java (2)

20-20: Club.create 메서드에 추가된 파일 매개변수에 null 전달

테스트 설정에서 Club.create 메서드 호출 시 파일 매개변수로 null을 전달하고 있습니다. 이는 변경된 메서드 시그니처에 맞게 수정된 것입니다.


28-28: 테스트 케이스에서 Club.create 메서드 호출 업데이트

createClub_Success 테스트 케이스에서도 Club.create 메서드 호출 시 파일 매개변수로 null을 전달하도록 수정되었습니다.

aics-admin/src/main/java/kgu/developers/admin/file/presentation/FileAdminControllerImpl.java (2)

3-10: 정적 임포트 및 패키지 구성 변경

파일 도메인 상수를 정적 임포트하고 패키지 구성을 정리했습니다. 이렇게 하면 코드가 더 간결해지고 가독성이 향상됩니다.


66-73: 클럽 파일 업로드 API 추가

클럽 이미지 업로드를 위한 새로운 엔드포인트가 추가되었습니다. 이 구현은 다른 파일 업로드 엔드포인트와 일관된 패턴을 따르고 있어 좋습니다.

aics-admin/src/testFixtures/java/club/application/ClubAdminFacadeTest.java (6)

19-21: 새로운 의존성 추가가 적절히 이루어졌습니다.

파일 관련 기능 추가에 필요한 import들이 잘 추가되었습니다.


29-31: 테스트 초기화에 파일 저장소 설정이 적절히 추가되었습니다.

FakeFileRepository와 FileQueryService를 생성하여 테스트 환경을 적절히 구성했습니다.


34-35: ClubCommandService 의존성 주입에 fileQueryService가 추가되었습니다.

ClubCommandService 생성자에 필요한 파라미터가 올바르게 전달되고 있습니다.


40-41: Club.create 메서드에 파일 파라미터 추가가 적절합니다.

Club 엔티티 생성 시 null을 전달하여 파일 없이도 생성이 가능하도록 했습니다.


54-54: 테스트용 fileId 설정이 적절합니다.

테스트에서 사용할 fileId 값을 적절히 설정했습니다.


57-57: createClub 메서드 호출에 fileId 파라미터가 추가되었습니다.

변경된 메서드 시그니처에 맞게 fileId를 전달하도록 테스트 코드가 수정되었습니다.

aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminControllerImpl.java (1)

36-36: fileId 파라미터가 적절히 전달되었습니다.

ClubAdminFacade.createClub 호출 시 fileId 파라미터가 올바르게 전달되고 있습니다.

aics-admin/src/main/java/kgu/developers/admin/file/presentation/FileAdminController.java (2)

3-8: import 문 정리가 잘 되었습니다.

정적 import와 일반 import를 적절히 구분하여 코드 가독성이 향상되었습니다.


80-93: 동아리 로고 이미지 업로드 API가 적절히 추가되었습니다.

동아리 로고 이미지 업로드를 위한 API가 기존 패턴과 일관되게 잘 구현되었습니다. API 설명과 파라미터 설명이 명확합니다.

aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminController.java (2)

6-6: 필요한 import가 적절히 추가되었습니다.

RequestParam 어노테이션 사용을 위한 import가 잘 추가되었습니다.


30-33: fileId 파라미터에 대한 문서화가 잘 되어있습니다.

fileId 파라미터에 대한 설명과 예시가
명확히 작성되어 있습니다. required=false로 설정하여 파일 없이도 동아리 생성이 가능하도록 한 것이 좋습니다.

aics-domain/src/main/java/kgu/developers/domain/club/domain/Club.java (2)

38-40: 파일 엔티티와의 관계가 적절히 설정되었습니다.

Club 엔티티와 FileEntity 간의 일대일 관계가 적절하게 설정되었습니다. @JoinColumn 어노테이션을 사용하여 관계의 외래 키를 명확하게 지정한 점이 좋습니다.


42-48: 클럽 생성 메서드가 파일 엔티티를 포함하도록 적절히 수정되었습니다.

create 메서드에 파일 파라미터를 추가하고 빌더 패턴에도 이를 반영하여 도메인 모델의 일관성을 유지했습니다.

aics-domain/src/testFixtures/java/mock/FakeTestContainer.java (1)

59-61: ClubCommandService 초기화가 적절히 수정되었습니다.

ClubCommandService의 생성자 매개변수에 FileQueryService를 추가하여 실제 구현과 테스트 환경이 일치하도록 수정한 것이 좋습니다.

aics-domain/src/main/java/kgu/developers/domain/club/application/command/ClubCommandService.java (1)

17-17: FileQueryService 의존성이 추가되었습니다.

클럽 생성 시 파일 처리를 위해 필요한 의존성이 적절하게 추가되었습니다.

aics-domain/src/testFixtures/java/club/application/ClubCommandServiceTest.java (1)

22-25: FileQueryService 테스트 설정이 적절히 추가되었습니다.

테스트 환경에 FakeFileRepositoryFileQueryService를 초기화하여 ClubCommandService의 새로운 의존성을 올바르게 처리했습니다.

aics-api/src/main/resources/db/data.sql (2)

53-57: 새로운 동아리 로고 이미지 데이터 추가 검토
이 구간에서는 CLUB 관련 로고 이미지에 대한 새 INSERT 구문이 추가되었습니다.

  • 추가된 항목들이 file_entity 테이블에 올바르게 삽입되고 있으며, 이후 클럽 테이블과의 매핑을 위해 순서대로 배정된 file_id 값(21~24)과 일치하는지 확인하시기 바랍니다.

72-78: 동아리 INSERT 문에 file_id 컬럼 추가 검토
이 부분에서는 클럽 테이블의 INSERT 구문에 새롭게 file_id 컬럼이 포함되어 클럽과 파일 엔티티 사이의 1:1 관계를 반영하고 있습니다.

  • 각 클럽 항목에 할당된 file_id(21, 22, 23, 24)가 file_entity 테이블 내 클럽 로고 데이터 순번과 올바르게 매칭되는지 다시 한 번 검증하시기 바랍니다.

@minjo-on minjo-on changed the title refactor/#218 club 이미지 추가 feature/#218 club 이미지 추가 Mar 11, 2025
@minjo-on minjo-on added ✨feature create new feature and removed 🔨refactor refactoring code labels Mar 11, 2025
Copy link
Contributor

@LeeShinHaeng LeeShinHaeng left a comment

Choose a reason for hiding this comment

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

빠른 QA 좋습니다!
LGTM 👍

@minjo-on minjo-on merged commit cf54e39 into develop Mar 11, 2025
5 checks passed
@minjo-on minjo-on deleted the refactor/#218-club-image branch March 11, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨feature create new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

동아리 이미지 추가
2 participants