Skip to content

Commit

Permalink
feat : Add image Column to table
Browse files Browse the repository at this point in the history
- 이미지컬럼을 추가한다

issue: #7
  • Loading branch information
bong6981 committed Apr 22, 2021
1 parent c6c4040 commit d48a5e5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 33 deletions.
16 changes: 8 additions & 8 deletions BE/src/main/java/com/team10/banchan/model/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ public class Item {
private final Set<DeliveryDay> deliveryDays;

Item(Long id, Long section, Long category,
TopImage topImage,
ItemImages itemImages,
Description description,
Prices prices,
Integer stock,
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -94,7 +94,7 @@ public void addDeliveryDay(DeliveryDay deliveryDay) {

public ItemDetail itemDetail() {
return ItemDetail.of(
topImage.getUrl(),
itemImages.getTopImage(),
thumbImagesUrl(),
description.getTitle(),
description.getDescription(),
Expand All @@ -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(),
Expand Down
30 changes: 30 additions & 0 deletions BE/src/main/java/com/team10/banchan/model/ItemImages.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
24 changes: 0 additions & 24 deletions BE/src/main/java/com/team10/banchan/model/TopImage.java

This file was deleted.

1 change: 1 addition & 0 deletions BE/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion BE/src/test/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit d48a5e5

Please sign in to comment.