Skip to content

Commit

Permalink
Merge pull request #18 from ghis22130/dto
Browse files Browse the repository at this point in the history
[BE] DTO 설계 
closes issue #8
  • Loading branch information
bong6981 committed Apr 21, 2021
2 parents 670d8a6 + 78ff8f9 commit a66c321
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 137 deletions.
104 changes: 104 additions & 0 deletions BE/src/main/java/com/team10/banchan/dto/ItemDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.team10.banchan.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public class ItemDetail {

private final String topImage;
private final List<String> thumbImages;

private final String title;
private final String productDescription;

private final String point;
private final String deliveryInfo;

private final String deliveryFee;
private final String nPrices;
private final String sPrices;

private final List<String> detailSection;
private final List<String> badges;

private ItemDetail(String topImage, List<String> thumbImages, String title, String productDescription, String point, String deliveryInfo, String deliveryFee, String nPrices, String sPrices, List<String> detailSection, List<String> badges) {
this.topImage = topImage;
this.thumbImages = thumbImages;
this.title = title;
this.productDescription = productDescription;
this.point = point;
this.deliveryInfo = deliveryInfo;
this.deliveryFee = deliveryFee;
this.nPrices = nPrices;
this.sPrices = sPrices;
this.detailSection = detailSection;
this.badges = badges;
}

public static ItemDetail of(String topImage, List<String> thumbImages,
String title, String productDescription,
String point, String deliveryInfo,
String deliveryFee, String nPrices, String sPrices,
List<String> detailSection, List<String> badges) {
return new ItemDetail(topImage, thumbImages, title, productDescription, point, deliveryInfo, deliveryFee, nPrices, sPrices, detailSection, badges);
}

@JsonProperty("top_image")
public String getTopImage() {
return topImage;
}

@JsonProperty("thumb_image")
public List<String> getThumbImages() {
return thumbImages;
}

@JsonProperty("product_description")
public String getTitle() {
return title;
}

@JsonProperty("product_description")
public String getProductDescription() {
return productDescription;
}

@JsonProperty("point")
public String getPoint() {
return point;
}

@JsonProperty("devliery_info")
public String getDeliveryInfo() {
return deliveryInfo;
}

@JsonProperty("devliery_fee")
public String getDeliveryFee() {
return deliveryFee;
}

@JsonProperty("n_prices")
public String getnPrices() {
return nPrices;
}


@JsonProperty("s_prices")
public String getsPrices() {
return sPrices;
}

@JsonProperty("detail_section")
public List<String> getDetailSection() {
return detailSection;
}

@JsonProperty("badge")
public List<String> getBadges() {
return badges;
}
}


28 changes: 28 additions & 0 deletions BE/src/main/java/com/team10/banchan/dto/ItemDetailResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.team10.banchan.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

public class ItemDetailResponse {

private final Long id;
private final ItemDetail itemDetail;

private ItemDetailResponse(Long id, ItemDetail itemDetail) {
this.id = id;
this.itemDetail = itemDetail;
}

public static ItemDetailResponse of(Long id, ItemDetail itemDetail) {
return new ItemDetailResponse(id, itemDetail);
}

@JsonProperty("hash")
public Long getId() {
return id;
}

@JsonProperty("data")
public ItemDetail getItemDetail() {
return itemDetail;
}
}
95 changes: 95 additions & 0 deletions BE/src/main/java/com/team10/banchan/dto/ItemSummary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.team10.banchan.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public class ItemSummary {

private final Long id;

private final String image;
private final String alt;

private final List<String> deliveryType;

private final String title;
private final String description;

private final String nPrice;
private final String sPrice;

private final List<String> badge;

private ItemSummary(Long id,
String image, String alt,
List<String> deliveryType,
String title, String description,
String nPrice, String sPrice,
List<String> badge) {
this.id = id;
this.image = image;
this.alt = alt;
this.deliveryType = deliveryType;
this.title = title;
this.description = description;
this.nPrice = nPrice;
this.sPrice = sPrice;
this.badge = badge;
}

public static ItemSummary of(Long id,
String image, String alt,
List<String> deliveryType,
String title, String description,
String nPrice, String sPrice,
List<String> badge) {
return new ItemSummary(id, image, alt, deliveryType, title, description, nPrice, sPrice, badge);
}

@JsonProperty("detail_hash")
public Long getId() {
return id;
}

@JsonProperty("image")
public String getImage() {
return image;
}

@JsonProperty("alt")
public String getAlt() {
return alt;
}

@JsonProperty("delivery_type")
public List<String> getDeliveryType() {
return deliveryType;
}

@JsonProperty("title")
public String getTitle() {
return title;
}

@JsonProperty("description")
public String getDescription() {
return description;
}

@JsonProperty("n_price")
public String getnPrice() {
return nPrice;
}

@JsonProperty("s_price")
public String getsPrice() {
return sPrice;
}

@JsonProperty("badge")
public List<String> getBadge() {
return badge;
}

}
9 changes: 5 additions & 4 deletions BE/src/main/java/com/team10/banchan/model/Badge.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.team10.banchan.model;

public class Badge {

private final BadgeType badgeType;

Badge(BadgeType badgeType) {
this.badgeType = badgeType;
}

public String name() {
return this.badgeType.name;
}

public static Badge event() {
return new Badge(BadgeType.EVENT);
}
Expand All @@ -19,6 +16,10 @@ public static Badge launching() {
return new Badge(BadgeType.LAUNCHING);
}

public String getName() {
return this.badgeType.name;
}

enum BadgeType {
EVENT("이벤트특가"),
LAUNCHING("런칭특가");
Expand Down
20 changes: 6 additions & 14 deletions BE/src/main/java/com/team10/banchan/model/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@

import org.springframework.data.annotation.Id;

import java.util.HashSet;
import java.util.Set;

public class Category {

@Id
private final Long id;
private final String name;
private final Set<Item> items;

Category(Long id, String name, Set<Item> items) {
Category(Long id, String name) {
this.id = id;
this.name = name;
this.items = items;
}

public Long getId() {
return id;
public static Category newCategory(String name) {
return new Category(null, name);
}

public Set<Item> getItems() {
return items;
public Long getId() {
return id;
}

public String getName() {
return name;
}

public static Category newCategory(String name) {
return new Category(null, name, new HashSet<>());
}
}
9 changes: 5 additions & 4 deletions BE/src/main/java/com/team10/banchan/model/DeliveryDay.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.team10.banchan.model;

public class DeliveryDay {

private final TheDayOfWeek theDayOfWeek;

DeliveryDay(TheDayOfWeek theDayOfWeek) {
this.theDayOfWeek = theDayOfWeek;
}

public String korean() {
return theDayOfWeek.korean;
}

public static DeliveryDay monday() {
return new DeliveryDay(TheDayOfWeek.MON);
}
Expand Down Expand Up @@ -39,6 +36,10 @@ public static DeliveryDay sunday() {
return new DeliveryDay(TheDayOfWeek.SUN);
}

public String korean() {
return theDayOfWeek.korean;
}

enum TheDayOfWeek {
MON("월"),
TUE("화"),
Expand Down
17 changes: 9 additions & 8 deletions BE/src/main/java/com/team10/banchan/model/DeliveryType.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.team10.banchan.model;

public class DeliveryType {

private final DeliveryTypeEnum deliveryTypeName;

DeliveryType(DeliveryTypeEnum deliveryTypeName) {
this.deliveryTypeName = deliveryTypeName;
}

public String getName() {
return deliveryTypeName.name;
}

public String getDetail() {
return deliveryTypeName.detail;
}

public static DeliveryType nationwide() {
return new DeliveryType(DeliveryTypeEnum.NATIONWIDE);
}
Expand All @@ -23,6 +16,14 @@ public static DeliveryType dawn() {
return new DeliveryType(DeliveryTypeEnum.DAWN);
}

public String getName() {
return deliveryTypeName.name;
}

public String getDetail() {
return deliveryTypeName.detail;
}

enum DeliveryTypeEnum {
NATIONWIDE("전국택배", "전국택배 (제주 및 도서산간 불가)"),
DAWN("새벽배송", "서울 경기 새벽배송");
Expand Down
24 changes: 24 additions & 0 deletions BE/src/main/java/com/team10/banchan/model/Description.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.team10.banchan.model;

public class Description {

private final String title;
private final String description;

Description(String title, String description) {
this.title = title;
this.description = description;
}

public static Description of(String title, String description) {
return new Description(title, description);
}

public String getTitle() {
return title;
}

public String getDescription() {
return description;
}
}
Loading

0 comments on commit a66c321

Please sign in to comment.