Skip to content

Conversation

@MEOHIN
Copy link
Collaborator

@MEOHIN MEOHIN commented Sep 17, 2025

📢 기능 설명

Wishlist 도메인 추가했습니다.

연결된 issue

close #8

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 이슈넘버를 적었는가?

Summary by CodeRabbit

  • New Features
    • Introduced Wishlist functionality, allowing users to save items to a wishlist, view entries with creation dates, and update item status (active or removed). New wishlists default to active. Lays groundwork for future item associations.
  • Chores
    • Updated ignore rules to exclude local development database files.

@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

Adds a Wishlist domain: new JPA entity with status enum, Spring Data repository, request/response DTOs with Lombok, and a mapper in the response DTO. Also updates .gitignore to ignore local H2 database files.

Changes

Cohort / File(s) Summary
Git ignore updates
\.gitignore
Adds ignore patterns for db_dev.mv.db and db_dev.trace.db under VS Code section.
Wishlist DTOs
src/main/java/com/back/domain/wishlist/dto/WishlistRequestDto.java, src/main/java/com/back/domain/wishlist/dto/WishlistResponseDto.java
Introduces request and response DTOs with Lombok; response includes static mapper from Wishlist to DTO.
Wishlist domain core
src/main/java/com/back/domain/wishlist/entity/Wishlist.java, src/main/java/com/back/domain/wishlist/enums/WishlistStatus.java, src/main/java/com/back/domain/wishlist/repository/WishlistRepository.java
Adds JPA entity with user relation and status enum, status values (ACTIVE, DELETED), and a Spring Data JPA repository.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Controller
  participant Service
  participant Repository
  participant DB
  note over Controller,Service: New Wishlist feature

  Client->>Controller: POST /wishlists (WishlistRequestDto)
  Controller->>Service: createWishlist(request)
  Service->>Repository: save(Wishlist)
  Repository->>DB: INSERT Wishlist
  DB-->>Repository: Persisted Wishlist
  Repository-->>Service: Wishlist
  Service-->>Controller: WishlistResponseDto.from(Wishlist)
  Controller-->>Client: 201 Created (ResponseDto)

  Client->>Controller: GET /wishlists/{id}
  Controller->>Service: getWishlist(id)
  Service->>Repository: findById(id)
  Repository-->>Service: Wishlist or null
  alt Found
    Service-->>Controller: WishlistResponseDto.from(Wishlist)
    Controller-->>Client: 200 OK (ResponseDto)
  else Not found
    Controller-->>Client: 404 Not Found
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

feat

Suggested reviewers

  • seungwookc97

Poem

In moonlit code, I hop with glee,
A wishlist born—so clean, so free.
ACTIVE dreams, DELETED past,
Repos burrow data fast.
DTOs nibble fields just right—
Mapper magic, byte by byte.
Thump! Ship it into night. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "[feat] Wishlist 도메인 추가#8" succinctly states the primary change (adding the Wishlist domain) and references the linked issue, so it accurately reflects the changeset.
Linked Issues Check ✅ Passed Linked issue #8 required adding a Wishlist entity, DTOs, and a repository; the changeset provides Wishlist.java, WishlistRequestDto.java, WishlistResponseDto.java, WishlistRepository.java, and WishlistStatus enum, which satisfy the coding objectives.
Out of Scope Changes Check ✅ Passed The only change outside the Wishlist code is a .gitignore addition for db_dev.* files; all other modifications implement the Wishlist domain per the linked issue, so there are no substantive out-of-scope code changes.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat#8

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

@MEOHIN MEOHIN changed the title [feat] Wishlist 도메인 추가 [feat] Wishlist 도메인 추가#8 Sep 17, 2025
@github-actions github-actions bot added the feat 새로운 기능 추가 label Sep 17, 2025
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: 0

🧹 Nitpick comments (8)
.gitignore (1)

39-41: Generalize H2 ignore patterns.
Covers files regardless of location/name variations.

Apply:

-db_dev.mv.db
-db_dev.trace.db
+*.mv.db
+*.trace.db
src/main/java/com/back/domain/wishlist/enums/WishlistStatus.java (1)

3-8: Remove unnecessary Lombok on enum.
@Getter has no effect (no fields); drop it and its import.

-import lombok.Getter;
-
-@Getter
 public enum WishlistStatus {
     ACTIVE,
     DELETED
 }
src/main/java/com/back/domain/wishlist/repository/WishlistRepository.java (1)

5-8: Redundant @repository on Spring Data interface.
Spring auto-detects JpaRepository beans; annotation/import can be removed.

-import org.springframework.stereotype.Repository;
-
-@Repository
 public interface WishlistRepository extends JpaRepository<Wishlist, Long> {
 }
src/main/java/com/back/domain/wishlist/dto/WishlistRequestDto.java (1)

16-21: Tighten validation: userId must be positive; reconsider client‑settable status.

  • Add @positive for userId.
  • Prefer server-controlled status for creates; split Create/Update DTOs or use validation groups.
 import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
@@
     @NotNull
+    @Positive
     private Long userId;
 
-    // 생성 시 기본값 ACTIVE, 필요시 상태 지정 업데이트용으로 재사용 가능
-    private WishlistStatus status;
+    // 상태는 서버에서 관리(생성 시 기본 ACTIVE). 업데이트 DTO에서만 허용 권장.
+    private WishlistStatus status;
src/main/java/com/back/domain/wishlist/entity/Wishlist.java (4)

12-16: Add table metadata and auditing listener.
Indexes help common queries; auditing simplifies timestamps.

-@Entity
-@Getter
-@Setter
-@NoArgsConstructor
-public class Wishlist {
+@Entity
+@Table(name = "wishlist",
+       indexes = {
+           @Index(name = "idx_wishlist_user_id", columnList = "user_id"),
+           @Index(name = "idx_wishlist_status", columnList = "status")
+       })
+@EntityListeners(AuditingEntityListener.class)
+@Getter
+@Setter
+@NoArgsConstructor
+public class Wishlist {

Add imports (top of file, alongside others):

+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;

22-22: Persist non-null createdAt automatically.
Use Spring Data auditing; mark non-updatable.

-    private LocalDateTime createdAt;
+    @CreatedDate
+    @Column(nullable = false, updatable = false)
+    private LocalDateTime createdAt;

If auditing isn’t enabled, add:

+    @PrePersist
+    void prePersist() {
+        if (createdAt == null) createdAt = LocalDateTime.now();
+        if (status == null) status = WishlistStatus.ACTIVE;
+    }

24-26: Set association to LAZY and non-null; name the FK.
Prevents eager loads and enforces integrity.

-    @ManyToOne
-    private User user;  // 찜한 사용자 (위시리스트의 주인)
+    @ManyToOne(fetch = FetchType.LAZY, optional = false)
+    @JoinColumn(name = "user_id", nullable = false)
+    private User user;  // 찜한 사용자 (위시리스트의 주인)

31-35: Harden status column mapping.
Name column explicitly; keep non-null; default handled in code.

     @Enumerated(EnumType.STRING)
-    @Column(nullable = false)
+    @Column(name = "status", nullable = false)
     // 위시리스트 상태 - 기본값은 ACTIVE (활성 상태)
     // ACTIVE: 찜한 상태, DELETED: 찜 해제한 상태 (Soft Delete)
     private WishlistStatus status = WishlistStatus.ACTIVE;

Optional: consider soft-delete helpers (@SQLDelete/@where) if you plan to hide DELETED rows by default.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f06ede and cbefc6a.

📒 Files selected for processing (6)
  • .gitignore (1 hunks)
  • src/main/java/com/back/domain/wishlist/dto/WishlistRequestDto.java (1 hunks)
  • src/main/java/com/back/domain/wishlist/dto/WishlistResponseDto.java (1 hunks)
  • src/main/java/com/back/domain/wishlist/entity/Wishlist.java (1 hunks)
  • src/main/java/com/back/domain/wishlist/enums/WishlistStatus.java (1 hunks)
  • src/main/java/com/back/domain/wishlist/repository/WishlistRepository.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/main/java/com/back/domain/wishlist/dto/WishlistRequestDto.java (1)
src/main/java/com/back/domain/wishlist/dto/WishlistResponseDto.java (1)
  • Getter (12-31)
src/main/java/com/back/domain/wishlist/dto/WishlistResponseDto.java (1)
src/main/java/com/back/domain/wishlist/dto/WishlistRequestDto.java (1)
  • Getter (10-21)
🔇 Additional comments (3)
.gitignore (1)

39-41: Good call ignoring local H2 artifacts.
Keeps noisy DB files out of VCS.

src/main/java/com/back/domain/wishlist/dto/WishlistResponseDto.java (2)

16-30: DTO mapping looks solid and null‑safe.
Builder mapping is clear; returns null for null source.


22-27: Avoid N+1 when mapping userId.
Ensure queries fetch-join user or access within an open session; otherwise LAZY init may trigger extra queries.

Would you confirm service/repository methods use fetch joins (e.g., join fetch w.user) when listing wishlists?

@seungwookc97 seungwookc97 merged commit 8c43a92 into dev Sep 18, 2025
2 checks passed
@MEOHIN MEOHIN deleted the feat#8 branch September 18, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] Wishlist 도메인 추가

3 participants