Skip to content

refactor/#230 게시글 고정 여부 추가#231

Merged
minjo-on merged 7 commits intodevelopfrom
refactor/#230-add-post-ispinned
Apr 1, 2025
Merged

refactor/#230 게시글 고정 여부 추가#231
minjo-on merged 7 commits intodevelopfrom
refactor/#230-add-post-ispinned

Conversation

@minjo-on
Copy link
Copy Markdown
Contributor

@minjo-on minjo-on commented Apr 1, 2025

Summary

게시글 작성, 수정 시 고정 여부 추가

Tasks

  • 게시글 작성 로직에 고정 여부 추가
  • 게시글 수정 로직에 고정 여부 추가

@minjo-on minjo-on added the 🔨refactor refactoring code label Apr 1, 2025
@minjo-on minjo-on requested a review from a team April 1, 2025 07:24
@minjo-on minjo-on self-assigned this Apr 1, 2025
@minjo-on minjo-on linked an issue Apr 1, 2025 that may be closed by this pull request
3 tasks
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 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은 게시글의 고정 기능을 추가하기 위해 여러 계층에서 변경이 이루어졌습니다. 게시글 생성 및 수정 과정에 isPinned라는 불리언 필드가 추가되어, 게시글이 상단에 고정될 수 있도록 서비스 로직과 도메인 모델이 업데이트되었습니다. 또한 API 요청 객체와 테스트 코드에서도 해당 필드가 반영되도록 수정되었습니다.

Changes

파일(들) 변경 사항 요약
aics-admin/src/.../PostAdminFacade.java createPostupdatePost 메서드 호출에 isPinned 파라미터 추가
aics-admin/src/.../PostCreateRequest.java
aics-admin/src/.../PostUpdateRequest.java
요청 객체에 boolean isPinned 필드 추가 및 관련 스키마 어노테이션 적용
aics-domain/src/.../PostCommandService.java createPostupdatePost 메서드 시그니처에 boolean isPinned 파라미터 추가, 내부 로직에 해당 파라미터 반영
aics-domain/src/.../Post.java create 메서드에 boolean isPinned 파라미터 추가, togglePinnedupdatePinned로 변경하여 직접 업데이트하도록 수정하고 기존 토글 메서드 재추가
aics-domain/src/testFixtures/.../PostCommandServiceTest.java 테스트 케이스에서 메서드 호출 시 추가된 boolean 파라미터(false)를 전달하도록 수정

Assessment against linked issues

Objective (관련 이슈) Addressed Explanation
게시글 고정 여부 추가 (#230)

Possibly related PRs

Suggested reviewers

  • LeeShinHaeng

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (2)
aics-domain/src/testFixtures/java/post/application/PostCommandServiceTest.java (1)

93-112: 고정 상태 토글 테스트 기능 확인 필요

이미 존재하는 togglePostPinStatus 테스트 케이스가 있는데, 새로 추가된 게시글 생성/수정 시의 고정 기능과 어떻게 상호작용하는지 테스트 케이스가 없습니다. 두 기능 간의 관계를 명확히 하는 추가 테스트가 필요할 수 있습니다.

다음과 같은 추가 테스트 케이스를 고려해보세요:

@Test
@DisplayName("게시글 생성 시 isPinned 값이 올바르게 설정되는지 확인")
public void createPost_WithIsPinned_Success() {
    // given
    String title = "test";
    String content = "test";
    Category category = NOTIFICATION;
    Long fileId = 1L;
    boolean isPinned = true;

    // when
    Long postId = postCommandService.createPost(title, content, category, fileId, isPinned);
    Post post = postQueryService.getById(postId);

    // then
    assertEquals(isPinned, post.isPinned());
}

@Test
@DisplayName("게시글 수정 시 isPinned 값이 올바르게 업데이트되는지 확인")
public void updatePost_WithIsPinned_Success() {
    // given
    Post post = Post.builder().build();
    boolean newPinnedStatus = !post.isPinned();

    // when
    postCommandService.updatePost(post, "title", "content", NOTIFICATION, 1L, newPinnedStatus);

    // then
    assertEquals(newPinnedStatus, post.isPinned());
}
aics-domain/src/main/java/kgu/developers/domain/post/application/command/PostCommandService.java (1)

45-47: 토글 메서드와 업데이트 메서드가 모두 존재합니다.

현재 isPinned 값을 직접 설정하는 updatePost 메서드와 토글하는 togglePostPinStatus 메서드가 모두 존재합니다. 두 기능이 모두 필요한지 검토해보세요. 만약 두 기능이 모두 필요하다면, 문서화 주석을 추가하여 각 메서드의 용도를 명확히 설명하는 것이 좋을 것 같습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d33707 and d5bbe93.

📒 Files selected for processing (6)
  • aics-admin/src/main/java/kgu/developers/admin/post/application/PostAdminFacade.java (1 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/post/presentation/request/PostCreateRequest.java (1 hunks)
  • aics-admin/src/main/java/kgu/developers/admin/post/presentation/request/PostUpdateRequest.java (1 hunks)
  • aics-domain/src/main/java/kgu/developers/domain/post/application/command/PostCommandService.java (1 hunks)
  • aics-domain/src/main/java/kgu/developers/domain/post/domain/Post.java (3 hunks)
  • aics-domain/src/testFixtures/java/post/application/PostCommandServiceTest.java (2 hunks)
🔇 Additional comments (12)
aics-admin/src/main/java/kgu/developers/admin/post/presentation/request/PostCreateRequest.java (1)

31-34: 게시글 고정 기능이 올바르게 추가되었습니다.

isPinned 필드가 적절히 추가되었으며, @Schema 어노테이션을 통해 필드의 설명, 예시값, 필수 여부가 명확하게 정의되어 있습니다. 이 변경은 PR 목표인 게시글 고정 기능 추가를 위한 필수적인 부분입니다.

aics-admin/src/main/java/kgu/developers/admin/post/presentation/request/PostUpdateRequest.java (1)

34-37: 게시글 수정 요청에 고정 기능이 올바르게 추가되었습니다.

isPinned 필드가 적절히 추가되었으며, @Schema 어노테이션을 통해 필드의 설명, 예시값, 필수 여부가 명확하게 정의되어 있습니다. 이 변경은 게시글 수정 시에도 고정 여부를 설정할 수 있도록 하는 PR 목표에 부합합니다.

aics-admin/src/main/java/kgu/developers/admin/post/application/PostAdminFacade.java (3)

22-25: 게시글 생성 시 고정 여부를 전달하는 로직이 올바르게 구현되었습니다.

PostCreateRequest에서 추가된 isPinned 필드를 서비스 계층으로 올바르게 전달하고 있습니다. 이는 게시글 생성 시 고정 여부를 설정할 수 있도록 하는 PR 목표를 달성합니다.


27-31: 게시글 수정 시 고정 여부를 전달하는 로직이 올바르게 구현되었습니다.

PostUpdateRequest에서 추가된 isPinned 필드를 서비스 계층으로 올바르게 전달하고 있습니다. 이는 게시글 수정 시 고정 여부를 변경할 수 있도록 하는 PR 목표를 달성합니다.


33-37: 기존 토글 기능과 새로운 고정 기능의 관계 검토 필요

togglePostPinStatus 메서드가 이미 존재하는데, 새로 추가된 isPinned 파라미터 기능과 중복될 가능성이 있습니다. 두 기능의 목적과 사용 시나리오를 명확히 구분하는 것이 좋겠습니다.

이 PR에서 기존 토글 기능과 새로 추가된 게시글 생성/수정 시 고정 기능 설정이 어떻게 상호작용하는지 확인이 필요합니다. 예를 들어:

  1. 게시글 생성/수정 시 isPinned로 고정 상태를 직접 설정함
  2. 기존의 togglePostPinStatus는 현재 상태를 반전시킴

이 두 기능이 명확히 구분되는지, 혹은 하나로 통합되어야 하는지 검토해보세요.

aics-domain/src/testFixtures/java/post/application/PostCommandServiceTest.java (2)

67-69: 게시글 생성 테스트에 고정 기능이 올바르게 추가되었습니다.

게시글 생성 기능 테스트에 새로운 isPinned 파라미터를 false로 설정하여 추가했습니다. 이는 서비스 계층의 변경 사항에 맞게 테스트를 업데이트한 것으로 적절합니다.


84-86: 게시글 수정 테스트에 고정 기능이 올바르게 추가되었습니다.

게시글 수정 기능 테스트에 새로운 isPinned 파라미터를 false로 설정하여 추가했습니다. 이는 서비스 계층의 변경 사항에 맞게 테스트를 업데이트한 것으로 적절합니다.

aics-domain/src/main/java/kgu/developers/domain/post/application/command/PostCommandService.java (2)

21-21: 게시글 생성 시 고정 여부를 설정할 수 있도록 개선되었습니다.

게시글 생성 메서드에 isPinned 매개변수가 추가되어 게시글 생성 시 고정 여부를 지정할 수 있게 되었습니다. 이 변경사항은 PR 목표에 잘 부합합니다.

Also applies to: 28-28


32-32: 게시글 수정 시 고정 여부를 변경할 수 있도록 개선되었습니다.

게시글 수정 메서드에 isPinned 매개변수가 추가되고, 해당 값을 사용하여 게시글의 고정 상태를 업데이트하는 로직이 추가되었습니다. 이 변경사항은 요구사항을 명확하게 구현했습니다.

Also applies to: 36-36

aics-domain/src/main/java/kgu/developers/domain/post/domain/Post.java (3)

68-68: 게시글 생성 시 고정 여부를 설정할 수 있도록 개선되었습니다.

게시글 생성 메서드에 isPinned 매개변수가 추가되어 게시글 생성 시 고정 여부를 지정할 수 있게 되었습니다. 이 변경사항은 PR 목표에 잘 부합합니다.

Also applies to: 73-73


92-94: 고정 여부를 직접 설정하는 메서드가
추가되었습니다.

게시글의 고정 상태를 직접 설정할 수 있는 updatePinned 메서드가 추가되었습니다. 이 메서드는 게시글 수정 기능에서 고정 여부를 업데이트하는 데 사용됩니다.


104-106: 원래 있던 토글 기능이 재구현되었습니다.

고정 상태를 직접 설정하는 기능을 추가하면서, 기존의 토글 기능도 함께 유지되었습니다. 이는 기존 코드와의 호환성을 유지하면서 새로운 기능을 추가하는 좋은 접근 방식입니다.

Copy link
Copy Markdown
Member

@LeeHanEum LeeHanEum left a comment

Choose a reason for hiding this comment

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

LGTM 👍
빠른 작업 감사합니다

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2025

Test Coverage Report

Overall Project 94.32% 🍏
Files changed 100% 🍏

Module Coverage
aics-admin 100% 🍏
aics-domain 91.56% 🍏
Files
Module File Coverage
aics-admin PostAdminFacade.java 100% 🍏
aics-domain Post.java 100% 🍏
PostCommandService.java 100% 🍏

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #231      +/-   ##
=============================================
+ Coverage      91.37%   91.42%   +0.05%     
- Complexity       158      159       +1     
=============================================
  Files             49       49              
  Lines            452      455       +3     
  Branches           9        9              
=============================================
+ Hits             413      416       +3     
  Misses            29       29              
  Partials          10       10              
Files with missing lines Coverage Δ Complexity Δ
...lopers/admin/post/application/PostAdminFacade.java 100.00% <100.00%> (ø) 5.00 <1.00> (ø)
...n/post/application/command/PostCommandService.java 90.47% <100.00%> (+0.47%) 5.00 <0.00> (ø)
...n/java/kgu/developers/domain/post/domain/Post.java 100.00% <100.00%> (ø) 9.00 <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 6d33707...2ccf9c0. Read the comment docs.

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

@minjo-on minjo-on merged commit ee2cf83 into develop Apr 1, 2025
5 checks passed
@minjo-on minjo-on deleted the refactor/#230-add-post-ispinned branch April 1, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨refactor refactoring code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

게시글 고정 여부 추가

2 participants