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

πŸ„ :: (Meogo-42) post good #43

Merged
merged 3 commits into from
Oct 2, 2024
Merged

πŸ„ :: (Meogo-42) post good #43

merged 3 commits into from
Oct 2, 2024

Conversation

meltapplee
Copy link
Member

@meltapplee meltapplee commented Sep 30, 2024

close #42
스크란샷 2024-09-30 23 39 29
스크란샷 2024-09-30 23 39 38

Summary by CodeRabbit

  • μƒˆλ‘œμš΄ κΈ°λŠ₯
    • 뢁마크 관리 κΈ°λŠ₯ μΆ”κ°€: μ‚¬μš©μžκ°€ νŠΉμ • 학ꡐ와 κ΄€λ ¨λœ 뢁마크λ₯Ό 생성, 쑰회 및 μ‚­μ œν•  수 μžˆμŠ΅λ‹ˆλ‹€.
    • "μ’‹μ•„μš”" κΈ°λŠ₯ μΆ”κ°€: μ‚¬μš©μžκ°€ κ²Œμ‹œλ¬Όμ— "μ’‹μ•„μš”"λ₯Ό μΆ”κ°€ν•˜κ³  μ‚­μ œν•  수 μžˆλŠ” κΈ°λŠ₯이 κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
  • 버그 μˆ˜μ •
    • κ²Œμ‹œλ¬Όμ˜ "μ’‹μ•„μš”" 수λ₯Ό κ΄€λ¦¬ν•˜λŠ” λ©”μ„œλ“œκ°€ κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
  • λ¬Έμ„œν™”
    • μƒˆλ‘œμš΄ REST μ»¨νŠΈλ‘€λŸ¬μ™€ μ„œλΉ„μŠ€ ν΄λž˜μŠ€μ— λŒ€ν•œ μ„€λͺ… μΆ”κ°€.

@meltapplee meltapplee added the κΈ°λŠ₯개발 make something label Sep 30, 2024
@meltapplee meltapplee self-assigned this Sep 30, 2024
Copy link

coderabbitai bot commented Sep 30, 2024

Walkthrough

이번 λ³€κ²½ 사항은 Bookmark, BookmarkRepository, BookmarkService, Good, GoodRepository, GoodController, GoodService, Post 클래슀 및 κ΄€λ ¨ νŒŒμΌμ„ ν¬ν•¨ν•˜μ—¬ 뢁마크 및 쒋은 κΈ°λŠ₯을 κ΄€λ¦¬ν•˜λŠ” μƒˆλ‘œμš΄ μ„œλΉ„μŠ€μ™€ 리포지토리 μΈν„°νŽ˜μ΄μŠ€λ₯Ό λ„μž…ν•©λ‹ˆλ‹€. 이 λ³€κ²½μœΌλ‘œ μ‚¬μš©μžκ°€ λΆλ§ˆν¬μ™€ 쒋은 κΈ°λŠ₯을 μΆ”κ°€ν•˜κ³  μ‚­μ œν•  수 μžˆλŠ” REST APIκ°€ 제곡되며, λ°μ΄ν„°λ² μ΄μŠ€μ™€μ˜ μƒν˜Έμž‘μš©μ„ μœ„ν•œ μƒˆλ‘œμš΄ λ©”μ„œλ“œκ°€ μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

Changes

파일 경둜 λ³€κ²½ μš”μ•½
src/main/kotlin/org/meogo/domain/bookmark/Bookmark.kt Bookmark 클래슀 μΆ”κ°€: UUID νƒ€μž…μ˜ id, Int νƒ€μž…μ˜ schoolId, User νƒ€μž…μ˜ user 속성 포함.
src/main/kotlin/org/meogo/domain/bookmark/BookmarkRepository.kt BookmarkRepository μΈν„°νŽ˜μ΄μŠ€ μΆ”κ°€: CRUD λ©”μ„œλ“œ 및 νŠΉμ • 학ꡐ와 μ‚¬μš©μžμ— λŒ€ν•œ λ©”μ„œλ“œ 포함.
src/main/kotlin/org/meogo/domain/bookmark/BookmarkService.kt BookmarkService 클래슀 μΆ”κ°€: 뢁마크λ₯Ό κ΄€λ¦¬ν•˜λŠ” λ©”μ„œλ“œ (execute, queryBookmarkedPost, queryIsBookmarked, deleteBookmark) 포함.
src/main/kotlin/org/meogo/domain/good/domain/Good.kt Good 클래슀 μΆ”κ°€: UUID νƒ€μž…μ˜ id와 μ‚¬μš©μž 및 κ²Œμ‹œλ¬Όκ³Όμ˜ 관계 μœ μ§€.
src/main/kotlin/org/meogo/domain/good/domain/GoodRepository.kt GoodRepository μΈν„°νŽ˜μ΄μŠ€ μΆ”κ°€: μ‚¬μš©μžμ™€ κ²Œμ‹œλ¬Όμ— λ”°λ₯Έ Good 객체 검색 λ©”μ„œλ“œ 포함.
src/main/kotlin/org/meogo/domain/good/presentation/GoodController.kt GoodController 클래슀 μΆ”κ°€: HTTP μš”μ²­μ„ μ²˜λ¦¬ν•˜λŠ” λ©”μ„œλ“œ (addGood, deleteGood) 포함.
src/main/kotlin/org/meogo/domain/good/service/GoodService.kt GoodService 클래슀 μΆ”κ°€: addGood 및 deleteGood λ©”μ„œλ“œλ₯Ό 톡해 κ²Œμ‹œλ¬Όμ— λŒ€ν•œ 쒋은 κΈ°λŠ₯을 관리.
src/main/kotlin/org/meogo/domain/post/domain/Post.kt Post 클래슀 μˆ˜μ •: deleteGood λ©”μ„œλ“œ μΆ”κ°€ 및 update λ©”μ„œλ“œμ— 선택적 λ§€κ°œλ³€μˆ˜ μΆ”κ°€.

Possibly related PRs

  • πŸ„ :: (Meogo-9) create reviewΒ #10: BookmarkService ν΄λž˜μŠ€λŠ” μ‚¬μš©μžμ™€ 학ꡐ에 μ—°κ΄€λœ 뢁마크λ₯Ό κ΄€λ¦¬ν•˜λ©°, μ΄λŠ” Review ν΄λž˜μŠ€μ™€ μœ μ‚¬ν•œ κ°œλ…μ  ꡬ쑰λ₯Ό κ°€μ§‘λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-11) all school reviewΒ #12: Review 클래슀 및 λ¦¬ν¬μ§€ν† λ¦¬λŠ” μ‚¬μš©μžμ™€ ν•™κ΅μ™€μ˜ 연관성을 가지며, μ΄λŠ” Bookmark ν΄λž˜μŠ€μ™€ μœ μ‚¬ν•œ κ΅¬μ‘°μž…λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-13) modif reviewΒ #15: Review 클래슀의 속성과 λ©”μ„œλ“œ μΆ”κ°€λŠ” μ‚¬μš©μž μƒν˜Έμž‘μš©μ— 쀑점을 두고 있으며, μ΄λŠ” Bookmark 클래슀의 μ‚¬μš©μž 쀑심 섀계와 μœ μ‚¬ν•©λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-20) user my pageΒ #21: UserRepository의 λ³€κ²½ 사항은 Bookmark와 Review λ§₯λ½μ—μ„œ μ‚¬μš©μž 관리λ₯Ό κ΄€λ ¨μ§“λŠ” μš”μ†Œμž…λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-28) query school postΒ #29: Post 클래슀의 μˆ˜μ • 사항은 μ‚¬μš©μž κ΄€λ ¨ 속성을 ν¬ν•¨ν•˜λ©°, μ΄λŠ” Bookmark와 Review 클래슀의 μ‚¬μš©μž 쀑심 섀계와 μΌμΉ˜ν•©λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-32) modify community postΒ #33: Post 클래슀의 μ—…λ°μ΄νŠΈλŠ” μ‚¬μš©μž κ΄€λ ¨ 속성과 λ©”μ„œλ“œλ₯Ό ν¬ν•¨ν•˜λ©°, μ΄λŠ” Bookmark와 Review 클래슀의 μ‚¬μš©μž μ—°κ΄€μ„±κ³Ό μœ μ‚¬ν•©λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-38) question crudΒ #39: CommentController의 λ³€κ²½ 사항은 μ‚¬μš©μž μƒν˜Έμž‘μš©μ„ ν¬ν•¨ν•˜λ©°, μ΄λŠ” Bookmark와 Review κΈ°λŠ₯의 핡심 μš”μ†Œμž…λ‹ˆλ‹€.
  • πŸ„ :: (Meogo-40) question tag detailΒ #41: Question 클래슀 및 λ¦¬ν¬μ§€ν† λ¦¬μ˜ μˆ˜μ • 사항은 μ‚¬μš©μž μƒν˜Έμž‘μš©κ³Ό 관련이 있으며, μ΄λŠ” Bookmark와 Review 클래슀의 μ‚¬μš©μž 쀑심 섀계와 μœ μ‚¬ν•©λ‹ˆλ‹€.

🐰 μƒˆλ‘œμš΄ κΈ°λŠ₯이 μƒκ²Όμ–΄μš”,
λΆλ§ˆν¬μ™€ 쒋은 κΈ°λŠ₯이 ν•¨κ»˜ν•΄μš”!
μ‚¬μš©μžμ™€ 학ꡐλ₯Ό μž‡λŠ” 닀리,
즐거운 클릭으둜 세상을 λ°ν˜€μš”.
λͺ¨λ‘ ν•¨κ»˜ 즐길 수 μžˆλŠ” 이 μˆœκ°„,
ν–‰λ³΅ν•œ 토끼가 좀을 μΆ°μš”! πŸŽ‰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ 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 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

@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: 13

🧹 Outside diff range and nitpick comments (4)
src/main/kotlin/org/meogo/domain/bookmark/BookmarkRepository.kt (2)

7-7: μΈν„°νŽ˜μ΄μŠ€ 선언이 μ μ ˆν•©λ‹ˆλ‹€. μž‘μ€ κ°œμ„  μ œμ•ˆμ΄ μžˆμŠ΅λ‹ˆλ‹€.

BookmarkRepository μΈν„°νŽ˜μ΄μŠ€κ°€ JpaRepository<Bookmark, UUID>λ₯Ό μ˜¬λ°”λ₯΄κ²Œ ν™•μž₯ν•˜κ³  μžˆμ–΄ Bookmark 엔티티에 λŒ€ν•œ 기본적인 CRUD μž‘μ—…μ΄ κ°€λŠ₯ν•©λ‹ˆλ‹€.

가독성을 높이기 μœ„ν•΄ Bookmark와 UUID에 λŒ€ν•œ import 문을 μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. λ‹€μŒκ³Ό 같이 λ³€κ²½ν•΄ λ³΄μ„Έμš”:

import org.meogo.domain.bookmark.Bookmark
import java.util.UUID

interface BookmarkRepository : JpaRepository<Bookmark, UUID> {
    // ...
}

8-12: μ‚¬μš©μž μ •μ˜ λ©”μ„œλ“œλ“€μ΄ 잘 κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μž‘μ€ κ°œμ„  μ œμ•ˆμ΄ μžˆμŠ΅λ‹ˆλ‹€.

μ„Έ 가지 μ‚¬μš©μž μ •μ˜ λ©”μ„œλ“œ(findAllBySchoolId, existsBySchoolIdAndUser, deleteBySchoolIdAndUser)κ°€ Spring Data JPA λͺ…λͺ… κ·œμΉ™μ„ λ”°λ₯΄κ³  있으며, 뢁마크 관리에 ν•„μš”ν•œ μž‘μ—…λ“€μ„ 적절히 닀루고 μžˆμŠ΅λ‹ˆλ‹€.

findAllBySchoolId λ©”μ„œλ“œμ˜ λ°˜ν™˜ νƒ€μž…μ„ κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒκ³Ό 같이 λ³€κ²½ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

fun findAllBySchoolId(schoolId: Int): List<Bookmark>

μ΄λ ‡κ²Œ ν•˜λ©΄ 빈 리슀트λ₯Ό λ°˜ν™˜ν•  수 μžˆμ–΄ null 체크λ₯Ό 쀄일 수 μžˆμŠ΅λ‹ˆλ‹€. JPAλŠ” κ²°κ³Όκ°€ 없을 λ•Œ 빈 μ»¬λ ‰μ…˜μ„ λ°˜ν™˜ν•˜λ―€λ‘œ, 이 방식이 더 Kotlin슀러운 μ ‘κ·Όλ²•μž…λ‹ˆλ‹€.

src/main/kotlin/org/meogo/domain/good/domain/Good.kt (1)

13-24: 클래슀 이름을 μž¬κ³ ν•΄ λ³΄μ„Έμš”.

Bookmarkμ—μ„œ Good으둜의 클래슀 이름 변경이 μ˜λ„λ₯Ό λͺ…ν™•νžˆ μ „λ‹¬ν•˜μ§€ μ•Šμ„ 수 μžˆμŠ΅λ‹ˆλ‹€. 클래슀의 λͺ©μ μ„ 더 잘 μ„€λͺ…ν•˜λŠ” 이름을 κ³ λ €ν•΄ λ³΄μ„Έμš”. 예λ₯Ό λ“€μ–΄, Like λ˜λŠ” Favoriteκ³Ό 같은 이름이 더 μ μ ˆν•  수 μžˆμŠ΅λ‹ˆλ‹€.

κ·Έ μ™Έμ˜ 클래슀 ꡬ쑰와 관계 섀정은 μ μ ˆν•©λ‹ˆλ‹€:

  • Post와 User μ—”ν‹°ν‹°μ™€μ˜ 관계가 잘 μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
  • 지연 λ‘œλ”©(LAZY)을 μ‚¬μš©ν•˜μ—¬ μ„±λŠ₯을 μ΅œμ ν™”ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.
  • BaseUUIDEntityλ₯Ό 상속받아 곡톡 κΈ°λŠ₯을 μž¬μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.
src/main/kotlin/org/meogo/domain/good/presentation/GoodController.kt (1)

1-28: λ¬Έμ„œν™” κ°œμ„  μ œμ•ˆ

μ½”λ“œμ˜ 가독성과 μœ μ§€λ³΄μˆ˜μ„±μ„ 높이기 μœ„ν•΄ KDoc 주석을 μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. μ»¨νŠΈλ‘€λŸ¬μ™€ 각 λ©”μ„œλ“œμ˜ λͺ©μ μ„ μ„€λͺ…ν•˜λŠ” 주석을 μΆ”κ°€ν•΄μ£Όμ„Έμš”.

λ‹€μŒκ³Ό 같이 KDoc 주석을 μΆ”κ°€ν•΄λ³΄μ„Έμš”:

/**
 * κ²Œμ‹œλ¬Όμ— λŒ€ν•œ 'μ’‹μ•„μš”' κΈ°λŠ₯을 κ΄€λ¦¬ν•˜λŠ” μ»¨νŠΈλ‘€λŸ¬μž…λ‹ˆλ‹€.
 *
 * @property goodService μ’‹μ•„μš” κ΄€λ ¨ λΉ„μ¦ˆλ‹ˆμŠ€ λ‘œμ§μ„ μ²˜λ¦¬ν•˜λŠ” μ„œλΉ„μŠ€
 */
@RestController
@RequestMapping("/good")
class GoodController(
    private val goodService: GoodService
) {
    /**
     * νŠΉμ • κ²Œμ‹œλ¬Όμ— μ’‹μ•„μš”λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
     *
     * @param postId μ’‹μ•„μš”λ₯Ό μΆ”κ°€ν•  κ²Œμ‹œλ¬Όμ˜ ID
     * @return μ’‹μ•„μš” μΆ”κ°€ κ²°κ³Ό
     */
    @PostMapping
    fun addGoodToPost(@RequestParam(name = "post_id") postId: Long): ResponseEntity<Any> {
        // ... (이전에 μ œμ•ˆν•œ κ΅¬ν˜„)
    }

    /**
     * νŠΉμ • κ²Œμ‹œλ¬Όμ—μ„œ μ’‹μ•„μš”λ₯Ό μ œκ±°ν•©λ‹ˆλ‹€.
     *
     * @param postId μ’‹μ•„μš”λ₯Ό μ œκ±°ν•  κ²Œμ‹œλ¬Όμ˜ ID
     * @return μ’‹μ•„μš” 제거 κ²°κ³Ό
     */
    @DeleteMapping
    fun removeGoodFromPost(@RequestParam(name = "post_id") postId: Long): ResponseEntity<Any> {
        // ... (이전에 μ œμ•ˆν•œ κ΅¬ν˜„)
    }
}
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 774f1c3 and 8d7635e.

πŸ“’ Files selected for processing (8)
  • src/main/kotlin/org/meogo/domain/bookmark/Bookmark.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/bookmark/BookmarkRepository.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/bookmark/BookmarkService.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/good/domain/Good.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/good/domain/GoodRepository.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/good/presentation/GoodController.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/good/service/GoodService.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/post/domain/Post.kt (1 hunks)
πŸ”‡ Additional comments (10)
src/main/kotlin/org/meogo/domain/good/domain/GoodRepository.kt (1)

1-10: μ „λ°˜μ μΈ ꡬ쑰가 잘 κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

νŒ¨ν‚€μ§€ μ„ μ–Έ, μž„ν¬νŠΈ, 그리고 μΈν„°νŽ˜μ΄μŠ€ μ •μ˜κ°€ μ μ ˆν•˜κ²Œ 이루어져 μžˆμŠ΅λ‹ˆλ‹€. JpaRepositoryλ₯Ό 상속받아 Good 엔티티에 λŒ€ν•œ 기본적인 CRUD μž‘μ—…μ„ μˆ˜ν–‰ν•  수 μžˆλ„λ‘ 잘 μ„€κ³„λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

src/main/kotlin/org/meogo/domain/bookmark/BookmarkRepository.kt (1)

1-6: νŒ¨ν‚€μ§€ μ„ μ–Έκ³Ό μž„ν¬νŠΈκ°€ μ μ ˆν•©λ‹ˆλ‹€.

νŒ¨ν‚€μ§€ μ„ μ–Έκ³Ό μž„ν¬νŠΈκ°€ BookmarkRepository μΈν„°νŽ˜μ΄μŠ€μ˜ κΈ°λŠ₯에 맞게 잘 κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/main/kotlin/org/meogo/domain/bookmark/Bookmark.kt (2)

1-10: νŒ¨ν‚€μ§€ μ„ μ–Έκ³Ό μž„ν¬νŠΈκ°€ μ μ ˆν•©λ‹ˆλ‹€.

νŒ¨ν‚€μ§€ μ„ μ–Έκ³Ό μž„ν¬νŠΈλœ ν΄λž˜μŠ€λ“€μ΄ Bookmark μ—”ν‹°ν‹°μ˜ κ΅¬ν˜„μ— ν•„μš”ν•œ μš”μ†Œλ“€μ„ 잘 ν¬ν•¨ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. λΆˆν•„μš”ν•œ μž„ν¬νŠΈλ„ μ—†μ–΄ 깔끔해 λ³΄μž…λ‹ˆλ‹€.


17-20: User μ—”ν‹°ν‹°μ™€μ˜ 관계 섀정이 μ μ ˆν•©λ‹ˆλ‹€.

User μ—”ν‹°ν‹°μ™€μ˜ λ‹€λŒ€μΌ 관계가 잘 μ„€μ •λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. FetchType.LAZYλ₯Ό μ‚¬μš©ν•˜μ—¬ μ„±λŠ₯ μ΅œμ ν™”λ₯Ό κ³ λ €ν•œ 점과 user_idλ₯Ό nullable = false둜 μ„€μ •ν•˜μ—¬ 데이터 무결성을 보μž₯ν•œ 점이 μ’‹μŠ΅λ‹ˆλ‹€.

src/main/kotlin/org/meogo/domain/good/domain/Good.kt (2)

3-10: import 문이 μ μ ˆν•©λ‹ˆλ‹€.

ν•„μš”ν•œ λͺ¨λ“  ν΄λž˜μŠ€κ°€ μ˜¬λ°”λ₯΄κ²Œ importλ˜μ—ˆμœΌλ©°, λΆˆν•„μš”ν•œ importλŠ” μ—†μŠ΅λ‹ˆλ‹€.


1-1: νŒ¨ν‚€μ§€ 변경이 μ μ ˆν•©λ‹ˆλ‹€.

νŒ¨ν‚€μ§€ ꡬ쑰가 κ°œμ„ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” μ½”λ“œ ꡬ쑰λ₯Ό 더 λͺ…ν™•ν•˜κ²Œ λ§Œλ“­λ‹ˆλ‹€.

λ‹€λ₯Έ νŒŒμΌμ—μ„œ 이 클래슀λ₯Ό importν•˜λŠ” 뢀뢄을 ν™•μΈν•˜κΈ° μœ„ν•΄ λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ„Έμš”:

βœ… Verification successful

Good 클래슀의 νŒ¨ν‚€μ§€ 변경이 μ˜¬λ°”λ₯΄κ²Œ μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λͺ¨λ“  import 문이 μƒˆλ‘œμš΄ νŒ¨ν‚€μ§€ 경둜λ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# μ„€λͺ…: Good 클래슀의 import 문을 κ²€μƒ‰ν•©λ‹ˆλ‹€.

# ν…ŒμŠ€νŠΈ: Good 클래슀의 import 문을 κ²€μƒ‰ν•©λ‹ˆλ‹€. μ˜ˆμƒ κ²°κ³Ό: μƒˆλ‘œμš΄ νŒ¨ν‚€μ§€ 경둜λ₯Ό μ‚¬μš©ν•˜λŠ” import 문만 λ‚˜νƒ€λ‚˜μ•Ό ν•©λ‹ˆλ‹€.
rg --type kotlin "import.*org\.meogo\.domain\.good\..*Good"

Length of output: 393

src/main/kotlin/org/meogo/domain/good/presentation/GoodController.kt (1)

14-18: 클래슀 선언이 μ μ ˆν•©λ‹ˆλ‹€

GoodController 클래슀의 선언이 Spring ν”„λ ˆμž„μ›Œν¬μ˜ λͺ¨λ²” 사둀λ₯Ό 잘 λ”°λ₯΄κ³  μžˆμŠ΅λ‹ˆλ‹€. @RestController와 @RequestMapping("/good") μ–΄λ…Έν…Œμ΄μ…˜μ΄ μ˜¬λ°”λ₯΄κ²Œ μ‚¬μš©λ˜μ—ˆμœΌλ©°, μƒμ„±μžλ₯Ό ν†΅ν•œ μ˜μ‘΄μ„± μ£Όμž…λ„ 잘 κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

src/main/kotlin/org/meogo/domain/good/service/GoodService.kt (2)

1-10: νŒ¨ν‚€μ§€ μ„ μ–Έ 및 μž„ν¬νŠΈκ°€ μ μ ˆν•©λ‹ˆλ‹€.

νŒ¨ν‚€μ§€ μ„ μ–Έκ³Ό ν•„μš”ν•œ λͺ¨λ“  ν΄λž˜μŠ€λ“€μ˜ μž„ν¬νŠΈκ°€ μ˜¬λ°”λ₯΄κ²Œ λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ½”λ“œ ꡬ쑰가 잘 μ •λ¦¬λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.


11-16: 클래슀 μ„ μ–Έκ³Ό μ˜μ‘΄μ„± μ£Όμž…μ΄ μ μ ˆν•©λ‹ˆλ‹€.

@Service μ–΄λ…Έν…Œμ΄μ…˜κ³Ό μƒμ„±μžλ₯Ό ν†΅ν•œ μ˜μ‘΄μ„± μ£Όμž…μ΄ μ˜¬λ°”λ₯΄κ²Œ κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 쒋은 κ΅¬μ‘°μž…λ‹ˆλ‹€.

λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ—¬ μ˜μ‘΄μ„±λ“€μ΄ ν”„λ‘œμ νŠΈμ— μ˜¬λ°”λ₯΄κ²Œ μ •μ˜λ˜μ–΄ μžˆλŠ”μ§€ ν™•μΈν•˜μ„Έμš”:

βœ… Verification successful

μ˜μ‘΄μ„± 확인 μ™„λ£Œ

GoodRepository, UserFacade, PostRepositoryκ°€ ν”„λ‘œμ νŠΈ 내에 μ˜¬λ°”λ₯΄κ²Œ μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# μ˜μ‘΄μ„± ν΄λž˜μŠ€λ“€μ΄ ν”„λ‘œμ νŠΈμ— μ‘΄μž¬ν•˜λŠ”μ§€ 확인

echo "Checking GoodRepository..."
rg --type kotlin "interface GoodRepository"

echo "Checking UserFacade..."
rg --type kotlin "class UserFacade"

echo "Checking PostRepository..."
rg --type kotlin "interface PostRepository"

Length of output: 620

src/main/kotlin/org/meogo/domain/post/domain/Post.kt (1)

Line range hint 52-58: null κ°’ μ²˜λ¦¬μ— λŒ€ν•œ κ³ λ € ν•„μš”

update λ©”μ„œλ“œμ—μ„œ schoolId, keyWord, image에 λŒ€ν•΄ null 값을 ν—ˆμš©ν•˜λ„λ‘ λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” μœ μ—°μ„±μ„ μ œκ³΅ν•˜μ§€λ§Œ, 잠재적인 문제λ₯Ό μ•ΌκΈ°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒ 사항을 κ³ λ €ν•΄λ³΄μ„Έμš”:

  1. null 값이 μ˜λ„μ μœΌλ‘œ ν—ˆμš©λ˜λŠ”μ§€ 확인
  2. ν•„μš”ν•œ 경우 null 값에 λŒ€ν•œ μœ νš¨μ„± 검사 μΆ”κ°€
  3. μ΄λŸ¬ν•œ 변경이 μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ˜ λ‹€λ₯Έ 뢀뢄에 λ―ΈμΉ˜λŠ” 영ν–₯ κ²€ν† 

λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ—¬ Post 클래슀의 μ‚¬μš©μ„ ν™•μΈν•˜μ„Έμš”:

import java.util.UUID

interface GoodRepository : JpaRepository<Good, UUID> {
fun findByUserAndPost(user: User, post: Post): Good
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

findByUserAndPost λ©”μ„œλ“œμ˜ λ°˜ν™˜ νƒ€μž…κ³Ό 이름을 μž¬κ³ ν•΄ λ³΄μ„Έμš”.

ν˜„μž¬ λ©”μ„œλ“œ μ •μ˜μ—λŠ” 두 가지 잠재적인 λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€:

  1. λ°˜ν™˜ νƒ€μž…μ΄ non-nullable Goodμž…λ‹ˆλ‹€. λ§Œμ•½ μΌμΉ˜ν•˜λŠ” μ—”ν‹°ν‹°κ°€ 없을 경우 μ΄λŠ” μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€.
  2. λ©”μ„œλ“œ 이름이 단일 μ—”ν‹°ν‹°λ₯Ό λ°˜ν™˜ν•  κ²ƒμž„μ„ μ•”μ‹œν•˜μ§€λ§Œ, μ‹€μ œλ‘œλŠ” μ‚¬μš©μžμ™€ κ²Œμ‹œλ¬Ό 쑰합에 λŒ€ν•΄ μ—¬λŸ¬ "μ’‹μ•„μš”"κ°€ μ‘΄μž¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 κ³ λ €ν•΄λ³΄μ„Έμš”:

-fun findByUserAndPost(user: User, post: Post): Good
+fun findByUserAndPost(user: User, post: Post): Good?

λ˜λŠ” μ—¬λŸ¬ μ—”ν‹°ν‹°λ₯Ό λ°˜ν™˜ν•˜λ„λ‘ λ³€κ²½:

-fun findByUserAndPost(user: User, post: Post): Good
+fun findAllByUserAndPost(user: User, post: Post): List<Good>

μ„ νƒν•œ μ ‘κ·Ό 방식에 따라 μ„œλΉ„μŠ€ λ ˆμ΄μ–΄μ—μ„œ 적절히 μ²˜λ¦¬ν•΄μ•Ό ν•©λ‹ˆλ‹€.

Committable suggestion was skipped due to low confidence.

Comment on lines +11 to +15
@Entity
class Bookmark(
id: UUID? = null,

val schoolId: Int? = 0,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

schoolId μ†μ„±μ˜ 널 ν—ˆμš© 여뢀와 기본값을 μž¬κ³ ν•΄ λ³΄μ„Έμš”.

schoolIdκ°€ 널을 ν—ˆμš©ν•˜κ³  κΈ°λ³Έκ°’μœΌλ‘œ 0을 μ‚¬μš©ν•˜λŠ” 것이 μ˜λ„λœ 섀계인지 확인해 μ£Όμ„Έμš”. λ§Œμ•½ schoolIdκ°€ ν•„μˆ˜ ν•„λ“œλΌλ©΄, 널을 ν—ˆμš©ν•˜μ§€ μ•Šλ„λ‘ λ³€κ²½ν•˜κ³  의미 μžˆλŠ” 기본값을 μ„€μ •ν•˜κ±°λ‚˜ κΈ°λ³Έκ°’ 없이 ν•„μˆ˜ νŒŒλΌλ―Έν„°λ‘œ λ§Œλ“œλŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 변경을 κ³ λ €ν•΄ λ³΄μ„Έμš”:

-    val schoolId: Int? = 0,
+    val schoolId: Int,

λ˜λŠ” 의미 μžˆλŠ” 기본값이 μ—†λ‹€λ©΄:

-    val schoolId: Int? = 0,
+    val schoolId: Int,

그리고 μƒμ„±μžμ—μ„œ schoolIdλ₯Ό ν•„μˆ˜ νŒŒλΌλ―Έν„°λ‘œ 받도둝 λ³€κ²½ν•˜μ„Έμš”.

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Entity
class Bookmark(
id: UUID? = null,
val schoolId: Int? = 0,
@Entity
class Bookmark(
id: UUID? = null,
val schoolId: Int,

@@ -0,0 +1,28 @@
package org.meogo.domain.good.presentation

import lombok.RequiredArgsConstructor
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Lombok μ–΄λ…Έν…Œμ΄μ…˜ 제거 ν•„μš”

Kotlinμ—μ„œλŠ” Lombok이 ν•„μš”ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. @RequiredArgsConstructor μ–΄λ…Έν…Œμ΄μ…˜κ³Ό importλ₯Ό μ œκ±°ν•΄μ£Όμ„Έμš”. Kotlin은 이미 μ£Ό μƒμ„±μžμ—μ„œ ν”„λ‘œνΌν‹°λ₯Ό μ„ μ–Έν•  λ•Œ μžλ™μœΌλ‘œ μƒμ„±μž λ§€κ°œλ³€μˆ˜λ₯Ό λ§Œλ“€μ–΄μ€λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•΄μ£Όμ„Έμš”:

-import lombok.RequiredArgsConstructor
-
 import org.meogo.domain.good.service.GoodService
 import org.springframework.http.HttpStatus
 import org.springframework.web.bind.annotation.DeleteMapping
@@ -10,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestParam
 import org.springframework.web.bind.annotation.ResponseStatus
 import org.springframework.web.bind.annotation.RestController

-@RequiredArgsConstructor
 @RestController
 @RequestMapping("/good")
 class GoodController(

Also applies to: 13-13

Comment on lines +19 to +22
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
fun addGood(@RequestParam(name = "post_id")postId: Long) =
goodService.addGood(postId)
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

addGood λ©”μ„œλ“œ κ°œμ„  μ œμ•ˆ

addGood λ©”μ„œλ“œμ˜ κ΅¬ν˜„μ€ λŒ€μ²΄λ‘œ μ˜¬λ°”λ₯΄μ§€λ§Œ, λ‹€μŒκ³Ό 같은 κ°œμ„ μ‚¬ν•­μ„ μ œμ•ˆν•©λ‹ˆλ‹€:

  1. @RequestParam μ–΄λ…Έν…Œμ΄μ…˜μ˜ 곡백을 일관성 있게 μˆ˜μ •ν•΄μ£Όμ„Έμš”.
  2. λ©”μ„œλ“œ 이름을 더 ꡬ체적으둜 λ³€κ²½ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€ (예: addGoodToPost).
  3. 였λ₯˜ 처리 λ‘œμ§μ„ μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•΄λ³΄μ„Έμš”:

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
fun addGoodToPost(@RequestParam(name = "post_id") postId: Long): ResponseEntity<Any> {
    return try {
        goodService.addGood(postId)
        ResponseEntity.status(HttpStatus.CREATED).build()
    } catch (e: Exception) {
        ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Failed to add good: ${e.message}")
    }
}

Comment on lines +24 to +27
@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping
fun deleteGood(@RequestParam(name = "post_id")postId: Long) =
goodService.deleteGood(postId)
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

deleteGood λ©”μ„œλ“œ κ°œμ„  μ œμ•ˆ

deleteGood λ©”μ„œλ“œλ„ addGood λ©”μ„œλ“œμ™€ μœ μ‚¬ν•œ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€:

  1. @RequestParam μ–΄λ…Έν…Œμ΄μ…˜μ˜ 곡백을 일관성 있게 μˆ˜μ •ν•΄μ£Όμ„Έμš”.
  2. λ©”μ„œλ“œ 이름을 더 ꡬ체적으둜 λ³€κ²½ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€ (예: removeGoodFromPost).
  3. 였λ₯˜ 처리 λ‘œμ§μ„ μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•΄λ³΄μ„Έμš”:

@DeleteMapping
fun removeGoodFromPost(@RequestParam(name = "post_id") postId: Long): ResponseEntity<Any> {
    return try {
        goodService.deleteGood(postId)
        ResponseEntity.noContent().build()
    } catch (e: Exception) {
        ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Failed to remove good: ${e.message}")
    }
}

μ΄λ ‡κ²Œ μˆ˜μ •ν•˜λ©΄ @ResponseStatus μ–΄λ…Έν…Œμ΄μ…˜μ΄ ν•„μš” μ—†μ–΄μ§€λ―€λ‘œ μ œκ±°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Comment on lines +28 to +31
fun queryBookmarkedPost(schoolId: Int): Int {
val posts = bookmarkRepository.findAllBySchoolId(schoolId)
return posts?.size ?: 0
}
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

λ©”μ„œλ“œ 이름 λ³€κ²½ 및 쿼리 μ΅œμ ν™” ν•„μš”

ν˜„μž¬ λ©”μ„œλ“œ 이름 queryBookmarkedPostλŠ” 뢁마크된 κ²Œμ‹œλ¬Όμ„ μ‘°νšŒν•˜λŠ” κ²ƒμ²˜λŸΌ λ³΄μ΄μ§€λ§Œ, μ‹€μ œλ‘œλŠ” 뢁마크 수λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€. λ˜ν•œ, λͺ¨λ“  뢁마크λ₯Ό μ‘°νšŒν•œ ν›„ 크기λ₯Ό κ³„μ‚°ν•˜λŠ” 것은 λΉ„νš¨μœ¨μ μΌ 수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€:

  1. λ©”μ„œλ“œ 이름을 countBookmarksBySchoolId둜 λ³€κ²½ν•˜μ—¬ μ˜λ„λ₯Ό λͺ…ν™•νžˆ ν•©λ‹ˆλ‹€.
  2. 쿼리λ₯Ό μ΅œμ ν™”ν•˜μ—¬ 직접 개수λ₯Ό λ°˜ν™˜ν•˜λ„λ‘ ν•©λ‹ˆλ‹€.
fun countBookmarksBySchoolId(schoolId: Int): Int {
    return bookmarkRepository.countBySchoolId(schoolId)
}

BookmarkRepository에 countBySchoolId λ©”μ„œλ“œλ₯Ό μΆ”κ°€ν•˜κ³ , 이λ₯Ό 톡해 λ°μ΄ν„°λ² μ΄μŠ€ λ ˆλ²¨μ—μ„œ 효율적으둜 개수λ₯Ό 계산할 수 μžˆμŠ΅λ‹ˆλ‹€.

Comment on lines +33 to +36
fun queryIsBookmarked(schoolId: Int): Boolean {
val user = userFacade.currentUser() ?: throw UserNotFoundException
return bookmarkRepository.existsBySchoolIdAndUser(schoolId, user)
}
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

μ˜ˆμ™Έ 처리 일관성 κ°œμ„  ν•„μš”

UserNotFoundException을 λ©”μ„œλ“œ λ‚΄λΆ€μ—μ„œ 직접 μ²˜λ¦¬ν•˜λŠ” 것은 일관성 μ—†λŠ” μ˜ˆμ™Έ 처리λ₯Ό μ•ΌκΈ°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ˜ˆμ™Έ 처리λ₯Ό μ„œλΉ„μŠ€ 레벨 μƒμœ„μ—μ„œ ν†΅μΌμ μœΌλ‘œ μ²˜λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄:

fun queryIsBookmarked(schoolId: Int): Boolean {
    val user = userFacade.currentUser()
    return bookmarkRepository.existsBySchoolIdAndUser(schoolId, user)
}

그리고 UserFacadeμ—μ„œ currentUser()κ°€ null을 λ°˜ν™˜ν•˜μ§€ μ•Šκ³  항상 UserNotFoundException을 λ˜μ§€λ„λ‘ μˆ˜μ •ν•˜μ„Έμš”. μ΄λ ‡κ²Œ ν•˜λ©΄ λͺ¨λ“  λ©”μ„œλ“œμ—μ„œ μΌκ΄€λœ λ°©μ‹μœΌλ‘œ μ‚¬μš©μž 쑴재 μ—¬λΆ€λ₯Ό μ²˜λ¦¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Comment on lines +38 to +41
fun deleteBookmark(schoolId: Int) {
val user = userFacade.currentUser() ?: throw UserNotFoundException
bookmarkRepository.deleteBySchoolIdAndUser(schoolId, user)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

νŠΈλžœμž­μ…˜ 처리 및 μ˜ˆμ™Έ 상황 κ³ λ € ν•„μš”

deleteBookmark λ©”μ„œλ“œμ— λͺ‡ 가지 κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€:

  1. @Transactional μ–΄λ…Έν…Œμ΄μ…˜μ΄ λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
  2. μ‚­μ œν•˜λ €λŠ” λΆλ§ˆν¬κ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ²½μš°μ— λŒ€ν•œ μ²˜λ¦¬κ°€ μ—†μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

@Transactional
fun deleteBookmark(schoolId: Int) {
    val user = userFacade.currentUser()
    val deleted = bookmarkRepository.deleteBySchoolIdAndUser(schoolId, user)
    if (deleted == 0) {
        // λΆλ§ˆν¬κ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ²½μš°μ— λŒ€ν•œ 처리
        // 예: throw BookmarkNotFoundException(schoolId, user.id)
    }
}

μ΄λ ‡κ²Œ ν•˜λ©΄ νŠΈλžœμž­μ…˜ μ²˜λ¦¬κ°€ 보μž₯되고, μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” 뢁마크λ₯Ό μ‚­μ œν•˜λ €λŠ” μ‹œλ„λ₯Ό 적절히 μ²˜λ¦¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Comment on lines +9 to +14
@Service
class BookmarkService(
private val bookmarkRepository: BookmarkRepository,
private val userFacade: UserFacade,
private val postRepository: PostRepository
) {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

μ‚¬μš©λ˜μ§€ μ•ŠλŠ” μ˜μ‘΄μ„± 제거 ν•„μš”

PostRepositoryκ°€ μ£Όμž…λ˜μ—ˆμ§€λ§Œ 클래슀 λ‚΄μ—μ„œ μ‚¬μš©λ˜μ§€ μ•Šκ³  μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” λΆˆν•„μš”ν•œ μ˜μ‘΄μ„±μ„ μ•ΌκΈ°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€:

 @Service
 class BookmarkService(
     private val bookmarkRepository: BookmarkRepository,
-    private val userFacade: UserFacade,
-    private val postRepository: PostRepository
+    private val userFacade: UserFacade
 ) {

λ§Œμ•½ PostRepositoryκ°€ ν–₯ν›„ μ‚¬μš©λ  μ˜ˆμ •μ΄λΌλ©΄, 주석을 μΆ”κ°€ν•˜μ—¬ κ·Έ μ˜λ„λ₯Ό λͺ…ν™•νžˆ ν•΄μ£Όμ„Έμš”.

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Service
class BookmarkService(
private val bookmarkRepository: BookmarkRepository,
private val userFacade: UserFacade,
private val postRepository: PostRepository
) {
@Service
class BookmarkService(
private val bookmarkRepository: BookmarkRepository,
private val userFacade: UserFacade
) {

Comment on lines +65 to +67
fun deleteGood() {
this.good -= 1
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

음수 κ°’ 체크 μΆ”κ°€ ν•„μš”

deleteGood() λ©”μ„œλ“œμ—μ„œ good 속성이 0 μ΄ν•˜λ‘œ 내렀가지 μ•Šλ„λ‘ μ²΄ν¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. μ΄λŠ” 잘λͺ»λœ μƒνƒœλ₯Ό λ°©μ§€ν•˜λŠ” 데 도움이 λ©λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 κ³ λ €ν•΄λ³΄μ„Έμš”:

 fun deleteGood() {
-    this.good -= 1
+    if (this.good > 0) {
+        this.good -= 1
+    }
 }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fun deleteGood() {
this.good -= 1
}
fun deleteGood() {
if (this.good > 0) {
this.good -= 1
}
}

@meltapplee meltapplee merged commit 5f035ca into main Oct 2, 2024
2 checks passed
@meltapplee meltapplee deleted the 42-post-good branch October 18, 2024 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

κ²Œμ‹œκΈ€ μ’‹μ•„μš”, μ’‹μ•„μš” μ·¨μ†Œ api
1 participant