From d48a5e5c770dea30926dafba79c6e73c8e029b10 Mon Sep 17 00:00:00 2001 From: bong6981 Date: Thu, 22 Apr 2021 16:43:31 +0900 Subject: [PATCH] feat : Add image Column to table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이미지컬럼을 추가한다 issue: #7 --- .../java/com/team10/banchan/model/Item.java | 16 +++++----- .../com/team10/banchan/model/ItemImages.java | 30 +++++++++++++++++++ .../com/team10/banchan/model/TopImage.java | 24 --------------- BE/src/main/resources/schema.sql | 1 + BE/src/test/resources/data.sql | 2 +- 5 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 BE/src/main/java/com/team10/banchan/model/ItemImages.java delete mode 100644 BE/src/main/java/com/team10/banchan/model/TopImage.java diff --git a/BE/src/main/java/com/team10/banchan/model/Item.java b/BE/src/main/java/com/team10/banchan/model/Item.java index 8a2115527..8d9d3d633 100644 --- a/BE/src/main/java/com/team10/banchan/model/Item.java +++ b/BE/src/main/java/com/team10/banchan/model/Item.java @@ -19,7 +19,7 @@ public class Item { private final Long category; @Embedded.Nullable - private final TopImage topImage; + private final ItemImages itemImages; @Embedded.Nullable private final Description description; @@ -36,7 +36,7 @@ public class Item { private final Set deliveryDays; Item(Long id, Long section, Long category, - TopImage topImage, + ItemImages itemImages, Description description, Prices prices, Integer stock, @@ -45,7 +45,7 @@ public class Item { this.id = id; this.section = section; this.category = category; - this.topImage = topImage; + this.itemImages = itemImages; this.description = description; this.prices = prices; this.stock = stock; @@ -57,11 +57,11 @@ public class Item { } public static Item newItem(Long section, Long category, - TopImage topImage, Description description, + ItemImages itemImages, Description description, Prices prices, Integer stock) { return new Item(null, section, category, - topImage, + itemImages, description, prices, stock, @@ -94,7 +94,7 @@ public void addDeliveryDay(DeliveryDay deliveryDay) { public ItemDetail itemDetail() { return ItemDetail.of( - topImage.getUrl(), + itemImages.getTopImage(), thumbImagesUrl(), description.getTitle(), description.getDescription(), @@ -112,8 +112,8 @@ public ItemDetail itemDetail() { public ItemSummary itemSummary() { return ItemSummary.of( id, - topImage.getUrl(), - topImage.getAlt(), + itemImages.getImage(), + itemImages.getAlt(), deliveryType(), description.getTitle(), description.getDescription(), diff --git a/BE/src/main/java/com/team10/banchan/model/ItemImages.java b/BE/src/main/java/com/team10/banchan/model/ItemImages.java new file mode 100644 index 000000000..2dd050be8 --- /dev/null +++ b/BE/src/main/java/com/team10/banchan/model/ItemImages.java @@ -0,0 +1,30 @@ +package com.team10.banchan.model; + +public class ItemImages { + + private final String alt; + private final String topImage; + private final String image; + + ItemImages(String alt, String topImage, String image) { + this.alt = alt; + this.topImage = topImage; + this.image = image; + } + + public static ItemImages of(String alt, String topImage,String image) { + return new ItemImages(alt, topImage, image); + } + + public String getAlt() { + return alt; + } + + public String getTopImage() { + return topImage; + } + + public String getImage() { + return image; + } +} diff --git a/BE/src/main/java/com/team10/banchan/model/TopImage.java b/BE/src/main/java/com/team10/banchan/model/TopImage.java deleted file mode 100644 index 96eb3e744..000000000 --- a/BE/src/main/java/com/team10/banchan/model/TopImage.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.team10.banchan.model; - -public class TopImage { - - private final String alt; - private final String topImage; - - TopImage(String alt, String topImage) { - this.alt = alt; - this.topImage = topImage; - } - - public static TopImage of(String alt, String topImage) { - return new TopImage(alt, topImage); - } - - public String getAlt() { - return alt; - } - - public String getUrl() { - return topImage; - } -} diff --git a/BE/src/main/resources/schema.sql b/BE/src/main/resources/schema.sql index c154828bb..87346403d 100644 --- a/BE/src/main/resources/schema.sql +++ b/BE/src/main/resources/schema.sql @@ -12,6 +12,7 @@ CREATE TABLE IF NOT EXISTS item ( `id` BIGINT AUTO_INCREMENT PRIMARY KEY, `section` BIGINT, `category` BIGINT, + `image` VARCHAR (255), `alt` VARCHAR(50), `top_image` VARCHAR(255), `title` VARCHAR(50), diff --git a/BE/src/test/resources/data.sql b/BE/src/test/resources/data.sql index ec97978ce..c36a1eaf7 100644 --- a/BE/src/test/resources/data.sql +++ b/BE/src/test/resources/data.sql @@ -2,7 +2,7 @@ INSERT INTO `section`(id, `name`) VALUES (1, 'main'); INSERT INTO `section`(id, `name`) VALUES (2, 'soup'); INSERT INTO `section`(id, `name`) VALUES (3, 'side'); INSERT INTO `category`(id, `name`) VALUES (1, 'best'); -INSERT INTO `item`(id, section, category, alt, top_image, title, description, n_price, s_price, delivery_fee, stock) VALUES (1, 1, 1, 'alt', 'url', 'title', 'description', 10000, 10000, 2500, 3); +INSERT INTO `item`(id, section, category, image, alt, top_image, title, description, n_price, s_price, delivery_fee, stock) VALUES (1, 1, 1, 'imageUrl', 'alt', 'url', 'title', 'description', 10000, 10000, 2500, 3); INSERT INTO `detail_section`(item, item_key, url) VALUES (1, 0, 'url1'); INSERT INTO `detail_section`(item, item_key, url) VALUES (1, 1, 'url2'); INSERT INTO `detail_section`(item, item_key, url) VALUES (1, 2, 'url3');