Repository: giwon-wg/Delivery_App
Pull request #12: Feat/add store dto
Author: login: alpomjeong
Created: 2025-04-22T09:34:39Z | Merged: 2025-04-22T10:04:41Z

가게의 requestdto와 responsedto를 작성해 보았습니다. 진행도중 엔티티도 일부 개선했습니다.

request에선 사용자가 직접 입력하지 않는 값들은 빼고 작성하였고,
response 에서는 모든 필드를 작성한 뒤 fromStore 메서드를 통해 엔티티를 dto로 변환 할 수 있도록 하였습니다.

헷갈리는 점으로는 엔티티 쪽 최하단 빌더 어노테이션이 붙은 생성자에서  rating, reviewCount, isOpen 등 사용자가 직접 입력 하지 않는 값들을 초기화 해두었는데 이걸 그냥 선언 당시에 초기화 하는게 나을지를 잘 모르겠습니다.


Diff:
diff --git a/src/main/java/com/example/delivery_app/domain/store/dto/StoreRequestDto.java b/src/main/java/com/example/delivery_app/domain/store/dto/StoreRequestDto.java
new file mode 100644
index 0000000..9e041b9
--- /dev/null
+++ b/src/main/java/com/example/delivery_app/domain/store/dto/StoreRequestDto.java
@@ -0,0 +1,24 @@
+package com.example.delivery_app.domain.store.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class StoreRequestDto {
+
+	private final String storeName;
+
+	private final String storeAddress;
+
+	private final String foodCategory;
+
+	private final String storePhone;
+
+	private final String storeIntro;
+
+	private final String minDeliveryPrice;
+
+	private final String deliveryTip;
+
+}
diff --git a/src/main/java/com/example/delivery_app/domain/store/dto/StoreResponseDto.java b/src/main/java/com/example/delivery_app/domain/store/dto/StoreResponseDto.java
new file mode 100644
index 0000000..118b125
--- /dev/null
+++ b/src/main/java/com/example/delivery_app/domain/store/dto/StoreResponseDto.java
@@ -0,0 +1,51 @@
+package com.example.delivery_app.domain.store.dto;
+
+import com.example.delivery_app.domain.store.entity.Store;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+@AllArgsConstructor
+public class StoreResponseDto {
+
+	private Long storeId;
+
+	private String storeName;
+
+	private String foodCategory;
+
+	private String storeAddress;
+
+	private String storePhone;
+
+	private String storeIntro;
+
+	private String minDeliveryPrice;
+
+	private String deliveryTip;
+
+	private String rating;
+
+	private String reviewCount;
+
+	private String isOpen;
+
+	public static StoreResponseDto fromStore(Store store) {
+		return StoreResponseDto.builder()
+			.storeId(store.getStoreId())
+			.storeName(store.getStoreName())
+			.foodCategory(store.getFoodCategory())
+			.storeAddress(store.getStoreAddress())
+			.storePhone(store.getStorePhone())
+			.minDeliveryPrice(store.getMinDeliveryPrice())
+			.deliveryTip(store.getDeliveryTip())
+			.rating(store.getRating())
+			.reviewCount(store.getReviewCount())
+			.isOpen(store.getIsOpen())
+			.build();
+	}
+
+}
diff --git a/src/main/java/com/example/delivery_app/domain/store/entity/Store.java b/src/main/java/com/example/delivery_app/domain/store/entity/Store.java
index a5d81f7..2915f85 100644
--- a/src/main/java/com/example/delivery_app/domain/store/entity/Store.java
+++ b/src/main/java/com/example/delivery_app/domain/store/entity/Store.java
@@ -6,10 +6,13 @@
 import jakarta.persistence.GenerationType;
 import jakarta.persistence.Id;
 import jakarta.persistence.Table;
+import lombok.Builder;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 
 @Getter
 @Entity
+@NoArgsConstructor
 @Table(name = "store")
 public class Store {
 
@@ -45,4 +48,20 @@ public class Store {
 
 	@Column(nullable = false)
 	private String isOpen;
+
+	@Builder
+	public Store(String storeName, String storeAddress, String storeIntro, String storePhone, String foodCategory,
+		String minDeliveryPrice, String deliveryTip) {
+		this.storeName = storeName;
+		this.storeAddress = storeAddress;
+		this.storeIntro = storeIntro;
+		this.storePhone = storePhone;
+		this.foodCategory = foodCategory;
+		this.minDeliveryPrice = minDeliveryPrice;
+		this.deliveryTip = deliveryTip;
+		this.rating = "0.0";
+		this.reviewCount = "0";
+		this.isOpen = "true";
+	}
 }
+


Reviews:
user: login: wannabeing
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-22T09:51:46Z
user: login: giwon-wg
body: LGTM
state: APPROVED
author_association: OWNER
submitted_at: 2025-04-22T09:53:58Z
user: login: alpomjeong
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-22T10:14:50Z

Review comments:
path: src/main/java/com/example/delivery_app/domain/store/dto/StoreRequestDto.java
user: login: wannabeing
body: 모든 필드가 `final`이니, `@AllArgsConstructor`보다 `@RequiredArgsConstructor`를 쓰시는게 좋을 것 같습니다!
`@AllArgsConstructor`는 사용하실 때 주의하셔서 사용해야한다고 합니다!

[@AllArgsConstructor 지양](https://www.inflearn.com/community/questions/1179578/%ED%98%B9%EC%8B%9C-allargsconstructor-%EB%A5%BC-%EC%A7%80%EC%96%91%ED%95%98%EC%8B%9C%EB%8A%94-%EC%9D%B4%EC%9C%A0%EA%B0%80-%EB%B9%8C%EB%8D%94-%ED%8C%A8%ED%84%B4%EC%9D%84-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-%EC%9C%84%ED%95%A8%EC%9D%B8%EA%B0%80%EC%9A%94?srsltid=AfmBOorvnA8lsNd1LqUOREyds_x4upGLwmk6v3wSQmXTK4nILwXxKUL4)
created_at: 2025-04-22T09:42:19Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,51 @@
+package com.example.delivery_app.domain.store.dto;
+
+import com.example.delivery_app.domain.store.entity.Store;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+@AllArgsConstructor
+public class StoreResponseDto {
+
+	private Long storeId;
+
+	private String storeName;
+
+	private String foodCategory;
+
+	private String storeAddress;
+
+	private String storePhone;
+
+	private String storeIntro;
+
+	private String minDeliveryPrice;
+
+	private String deliveryTip;
+
+	private String rating;
+
+	private String reviewCount;
+
+	private String isOpen;
+
+	public static StoreResponseDto fromStore(Store store) {
path: src/main/java/com/example/delivery_app/domain/store/dto/StoreResponseDto.java
user: login: wannabeing
body: 빌더 패턴 너무 좋은 것 같습니다! 👍
created_at: 2025-04-22T09:45:44Z
author_association: COLLABORATOR
path: src/main/java/com/example/delivery_app/domain/store/dto/StoreRequestDto.java
user: login: alpomjeong
body: 의견 반영해서 수정하겠습니다!
created_at: 2025-04-22T10:14:50Z
author_association: COLLABORATOR

PR comments:
user: login: wannabeing
created_at: 2025-04-22T09:51:25Z
body: 엔티티 쪽 최하단 빌더 어노테이션이 붙은 생성자에서 rating, reviewCount, isOpen 등 사용자가 직접 입력 하지 않는 값들을 초기화 해두었는데 이걸 그냥 선언 당시에 초기화 하는게 나을지를 잘 모르겠습니다.

→ 생성자가 여럿이고 다른 초기값을 넣을 수 있다면 필드에서 초기화하는 것이 좋다고 생각하는데,
현재로써는 상관없다는 의견입니다!

`@Column(nullable = false, columnDefinition = "BIGINT DEFAULT 0")` 이러한 느낌으로
JPA가 매핑시, 해당 컬럼의 기본값을 설정해주는 `columnDefinition` 속성도 있다고 합니다!
author_association: COLLABORATOR
user: login: giwon-wg
created_at: 2025-04-22T09:53:41Z
body: Assignees에는 작성자 본인만 적으셔도 됩니다.
author_association: OWNER