From f1ae6748fe1da4615e4f7fb7a464ed6bed9c75de Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Mon, 26 Apr 2021 15:15:56 +0900 Subject: [PATCH 01/18] =?UTF-8?q?feat:=20JDBC=EC=97=B0=EB=8F=99=20-=20cate?= =?UTF-8?q?gory=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gradle/6.8.3/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../SideDish/SideDishApplication.java | 6 +- .../domain/CategoryMockRepository.java | 17 -- .../SideDish/domain/CategoryRepository.java | 4 +- .../SideDish/domain/DishMockRepository.java | 217 ------------------ .../SideDish/domain/DishRepository.java | 4 +- .../SideDish/service/CategoryService.java | 5 - .../SideDish/service/DishService.java | 5 - .../src/main/resources/application.properties | 2 + backend/src/main/resources/data.sql | 6 + backend/src/main/resources/schema.sql | 10 +- 12 files changed, 20 insertions(+), 256 deletions(-) delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryMockRepository.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishMockRepository.java create mode 100644 backend/src/main/resources/data.sql diff --git a/backend/.gradle/6.8.3/fileHashes/fileHashes.lock b/backend/.gradle/6.8.3/fileHashes/fileHashes.lock index aa5895abac5ab02a173f71e963b5d6d9191f2ef7..db29074defb084c5f2f148c012c74e90fd0f9271 100644 GIT binary patch literal 17 TcmZQx;<;XitG1wm0Rln*D2xMt literal 17 TcmZQx;<;XitG1wm0Rq$jC|(0m diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 477ff4e56333391b9cbdb7d78389103dbfd1591b..e067c8965f34ce9ac7d684d526e6acf7bb2739c2 100644 GIT binary patch literal 17 UcmZSX+g@Tc(fO$n0|Yn#05M<$8UO$Q literal 17 UcmZSX+g@Tc(fO$n0|aOS05M4f0{{R3 diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/SideDishApplication.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/SideDishApplication.java index 60bdbe314..42166d35c 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/SideDishApplication.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/SideDishApplication.java @@ -6,11 +6,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; -// FIXME: DB 연동을 무효화하기 위해서 임시로 exclude 함, 나중에 수정할 예정 -@SpringBootApplication(exclude = { - DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class, - HibernateJpaAutoConfiguration.class}) +@SpringBootApplication public class SideDishApplication { public static void main(String[] args) { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryMockRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryMockRepository.java deleted file mode 100644 index cdf6378dc..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryMockRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import java.util.Arrays; -import java.util.List; - -public class CategoryMockRepository implements CategoryRepository { - private final List categories = Arrays.asList( - new Category(1, "모두가 좋아하는 든든한 메인요리", "/main"), - new Category(2, "뜨끈하고 시원한 국물요리", "/soup"), - new Category(3, "밥도둑이 여기있다! 반찬요리", "/side") - ); - - @Override - public List findAll() { - return categories; - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java index 8d24c53bd..17311be6d 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java @@ -1,7 +1,9 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.repository.CrudRepository; + import java.util.List; -public interface CategoryRepository { +public interface CategoryRepository extends CrudRepository { List findAll(); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishMockRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishMockRepository.java deleted file mode 100644 index d57a07409..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishMockRepository.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static com.codesquad.sidedish.SideDish.domain.Dish.Builder; - -public class DishMockRepository implements DishRepository { - Map dishes = new LinkedHashMap<>(); - - public DishMockRepository() { - dishes.put("HBDEF", new Builder() - .detailHash("HBDEF") - .categoryId(1) // 메인요리 - .title("[미노리키친] 규동 250g") - .description("일본인의 소울푸드! 한국인도 좋아하는 소고기덮밥") - .badges(Arrays.asList("이벤트특가", "메인특가")) - .salePrice(5200) - .price(6500) - .point(52) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/2d3f99a9a35601f4e98837bc4d39b2c8.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4cce011a4a352c22cd399a60271b4921.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/6ef14155afc5b47e8c9efd762f7a6096.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/8744504ff3bc315f901dca1f26fe63a1.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/e30bd6de9340fc05db3cd1d1329b2c56.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/9c2c53b40a11b79c90549a058c2da4b7.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/70b0c77d3ef5cdd6269588685bbefe43.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/72f1049b047f65f42a267d5bbd1e6204.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/768afd17faa8bf3461b8160ba0aa26bf.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/95816f09d3294641f2e0feacaa739991.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/2450219a4686d9d6d579fc04020929b4.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4971475295545ec336c9479fabb25364.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/a8c434715709fe855f3ea1554ec362b6.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/b2b3d0d2107ab91b16e0eb804cd84bc9.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/c0dd6887c9d9368604fc70d7fc3c4598.jpg" - )) - .build()); - - dishes.put("HDF73", new Builder() - .detailHash("HDF73") - .categoryId(1) // 메인요리 - .title("[빅마마의밥친구] 아삭 고소한 연근고기조림 250g") - .description("편식하는 아이도 좋아하는 건강한 연근조림") - .price(5500) - .point(55) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/7674311a02ba7c88675f3186ddaeef9e.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0f95f44ea8e2e7930321def493753a48.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/2d408898494ac950d7d2cfd6c36d59c2.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/62c8bb77facfc9c3be81f9bf45b27f2a.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/f6d73afc0ebc1efa71eaea32e9d846f2.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/5f73c5c80b62ef63c8a8eecefe32fc29.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0253cdebc4972fefd6b94458024fe765.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/3299da0677b50c8c519adc0335271c49.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0642265b65dcc2490ab164ff428cbfe2.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/695683493c1ae475a175475f50d3259f.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/c8f9bed4f5c07585b869e3d171904a93.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d2e3274c95c832bc9bfbcebbd548f61b.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d9e4fa00652483d74b46317d38159a2f.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d7799b67683128642453f9e2b4c8ce84.jpg" - )) - .build()); - - dishes.put("HAA47", new Builder() - .detailHash("HAA47") - .categoryId(2) // 국. 찌개 - .title("[집밥의완성] 스키야키 1.5kg (2~3인분)") - .description("진한 풍미의 일본식 전골, 스키야키") - .badges(Arrays.asList("이벤트특가")) - .salePrice(10000) - .price(19800) - .point(100) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/4e96f386d5a5c4459bc0ac6ffd0c1fce.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/4e96f386d5a5c4459bc0ac6ffd0c1fce.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/00327d0df92e29bad02e7387349bed53.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/781fea32c56eb102429902a2f62cbaf3.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/edd7a54096d6df1b8bc8b318cea0191c.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/fb8e6e21faa8284021c1b1c7a1ae1281.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/36a0566d2fb69a4bcea946727181836d.jpg" - )) - .build()); - - dishes.put("H26C7", new Builder() - .detailHash("H26C7") - .categoryId(2) // 국. 찌개 - .title("[모이세] 육개장 1팩(600g)") - .description("제주3대해장국 맛집의 인기메뉴") - .badges(Arrays.asList("론칭특가")) - .salePrice(4400) - .price(5500) - .point(44) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/8fd330b5f5dbccbcbf4f5731e5e9e29b.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/2ad963a9f63d371826748c852a0025c3.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/f945d8ac1dccc3f931bcaf35de5de582.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/bacb0b8186371bfafbd92dbeec718e13.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b96b02e9a956c6d5ad1e10eb14ba81e0.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/3d67aabd2751620367e1d1ac3e3d7ef2.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/855b42b4e80162e6930f06aa80bd1272.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/1966de56cf138639d5d50d4bf2db8e72.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b3dd54082745d1188f3a6e582e7cd993.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/4a6fd1fd1116c14aa6aef5e6851ab6a9.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/7e12275d669102d0269278a7c91ab49d.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/ab34ea3755f59a21662266eb62b7bc4b.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b0a70ff59a3b5360b6246b507693c4d4.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/dc772923b4a2e053f1baf68fa28a48ee.jpg" - )) - .build()); - - dishes.put("H602F", new Builder() - .detailHash("H602F") - .categoryId(3) // 반찬 - .title("[미노리키친] 일본식 우엉조림(킨피라고보) 80g") - .description("한국식 우엉조림과는 다른 진한 감칠맛") - .price(3300) - .point(33) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/422befe07f7e2860b9a83a8d7049ec2e.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c8c8045696b4692107ef28c8b445ca42.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/edc6bae2e2663f05b4e8eb5a2b95d68f.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c935f5913dc66b11ebceeef85485c438.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/7c1e24867611394f04b37d05593e21ba.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/670e7deefe1d84a4f4e058655fbd4d7c.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/1898cda038e92454395b8ffca8cd4393.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49516d302dad870fbdd75cf98a01eae4.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c1bb6fe4f72fcea27ea989ae48c61c86.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49afed8d3ec417b39ce8de456fc6661c.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/e62762e63f3e12dc2857a065badf1eea.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/31103ab946bff52b709ec6891e768c05.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/f84dc16f4f6d97661bd13d587a72d6b1.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H602F/fd3f49614f731a0610a5409c0deb3c60.jpg" - )) - .build()); - - dishes.put("H0FC6", new Builder() - .detailHash("H0FC6") - .categoryId(3) // 반찬 - .title("[마더앤찬] 명란치즈계란말이 230g") - .description("아이반찬으로 최고 계란말이") - .badges(Arrays.asList("이벤트특가")) - .salePrice(3870) - .price(4300) - .point(38) - .quantity(5) - .deliveryFee(2500) - .deliveryTypes(Arrays.asList("새벽배송", "전국택배")) - .deliveryInfo("서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가) [화 · 수 · 목 · 금 · 토] 수령 가능한 상품입니다.") - .image("http://public.codesquad.kr/jk/storeapp/data/f6817349118d4c671da8dca9065649a9.jpg") - .thumbImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/43c38eeffa556554c9b06301eb3e85b2.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/92f556b605c4a84813070d7214c4f336.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/538b8ab021c7814aa4af860d94f81287.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/adaef08ab0680b087096afa0f0070fad.jpg")) - .detailImages(Arrays.asList( - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/341b8605fa224ec1808c4f169097d170.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/0228d4cb660a3cca06952917bd024dcb.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e027227f61a93b6473e8c4bbd5c3de74.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/03ac0b09199421bb61727c667c2361f6.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/cbe4a3e12b7bdba5cf410e0e19dcf1ca.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/b58fa5791b67db106524b48442cb1c6a.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/82cfe0332f0e1c927a23b79f1d152430.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/390ca9ad5a574cbe7f3f6e26871f6690.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e113889a6120357c8e6196802a9f155b.jpg", - "http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/967e8e1ef357e9722b796e2bcb09ba3d.jpg" - )) - .build()); - - - // TODO: main(메인) 2개, soup(국) 2개, side(반찬) 2개 예시 하드코딩으로 채워넣기 - dishes.put("", new Builder() - .build()); - } - - @Override - public List findAllByCategoryId(long categoryId) { - return dishes.values().stream() - .filter(dish -> dish.getCategoryId() == categoryId) - .collect(Collectors.toList()); - } - - @Override - public Dish findByDetailHash(String detailHash) { - return dishes.get(detailHash); - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java index bb0c6f9d4..de2dc039e 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java @@ -1,8 +1,10 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.repository.CrudRepository; + import java.util.List; -public interface DishRepository { +public interface DishRepository extends CrudRepository { List findAllByCategoryId(long categoryId); Dish findByDetailHash(String detailHash); diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/CategoryService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/CategoryService.java index 90c13dc60..42dd88a30 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/CategoryService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/CategoryService.java @@ -1,6 +1,5 @@ package com.codesquad.sidedish.SideDish.service; -import com.codesquad.sidedish.SideDish.domain.CategoryMockRepository; import com.codesquad.sidedish.SideDish.domain.CategoryRepository; import com.codesquad.sidedish.SideDish.dto.CategoryDto; import org.springframework.stereotype.Service; @@ -16,10 +15,6 @@ public CategoryService(CategoryRepository categoryRepository) { this.categoryRepository = categoryRepository; } - public CategoryService() { - this(new CategoryMockRepository()); - } - public List getList() { return categoryRepository.findAll() .stream().map(CategoryDto::from) diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 25cb1cab6..f89a8815f 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -1,7 +1,6 @@ package com.codesquad.sidedish.SideDish.service; import com.codesquad.sidedish.SideDish.domain.Dish; -import com.codesquad.sidedish.SideDish.domain.DishMockRepository; import com.codesquad.sidedish.SideDish.domain.DishRepository; import com.codesquad.sidedish.SideDish.dto.DishDetailDto; import com.codesquad.sidedish.SideDish.dto.DishDto; @@ -22,10 +21,6 @@ public DishService(DishRepository dishRepository) { this.dishRepository = dishRepository; } - public DishService() { - this(new DishMockRepository()); - } - public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { Dish dish = dishRepository.findByDetailHash(detailHash); boolean refreshable = dish.refreshable(lastUpdated); diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 466a1cd2e..fe60961c2 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -2,6 +2,8 @@ spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?autoReconnect=true&us spring.datasource.username=bat spring.datasource.password=bat1234 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + spring.datasource.schema=classpath:schema.sql spring.datasource.initialization-mode=always + spring.jackson.serialization.INDENT_OUTPUT=true diff --git a/backend/src/main/resources/data.sql b/backend/src/main/resources/data.sql new file mode 100644 index 000000000..e783bb12f --- /dev/null +++ b/backend/src/main/resources/data.sql @@ -0,0 +1,6 @@ +INSERT INTO sidedish.category + (id, category_name, end_point) +VALUES + (1, '메인요리', '/main'), + (2, '국.찌개', '/soup'), + (3, '반찬', '/side'); diff --git a/backend/src/main/resources/schema.sql b/backend/src/main/resources/schema.sql index 1a0428c9f..48536fe6d 100644 --- a/backend/src/main/resources/schema.sql +++ b/backend/src/main/resources/schema.sql @@ -34,12 +34,12 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`delivery` ( -- ----------------------------------------------------- -- Table `sidedish`.`menu` -- ----------------------------------------------------- -DROP TABLE IF EXISTS `sidedish`.`menu` ; +DROP TABLE IF EXISTS `sidedish`.`category` ; -CREATE TABLE IF NOT EXISTS `sidedish`.`menu` ( - `id` INT(11) NOT NULL, - `name` VARCHAR(45) NOT NULL, - `endpoint` VARCHAR(45) NOT NULL, +CREATE TABLE IF NOT EXISTS `sidedish`.`category` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `category_name` VARCHAR(45) NOT NULL, + `end_point` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; From f307e561e94f5a9597190811ffd0e9d3e29127d3 Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Mon, 26 Apr 2021 16:11:49 +0900 Subject: [PATCH 02/18] feat: Add category test code --- .../.gradle/6.8.3/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../sidedish/SideDish/domain/Category.java | 16 ++++++- .../SideDish/SideDishApplicationTests.java | 42 +++++++++++++++++- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/backend/.gradle/6.8.3/fileHashes/fileHashes.lock b/backend/.gradle/6.8.3/fileHashes/fileHashes.lock index db29074defb084c5f2f148c012c74e90fd0f9271..0745dda007f8f78f50e8a411fd0c449b4765bf3e 100644 GIT binary patch literal 17 UcmZQx;<;XitG1wm0Sp-P04S&fng9R* literal 17 TcmZQx;<;XitG1wm0Rln*D2xMt diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index e067c8965f34ce9ac7d684d526e6acf7bb2739c2..9d6d5cf511b956188f3bb69920457d35bf0db5c4 100644 GIT binary patch literal 17 UcmZSX+g@Tc(fO$n0|dMS05T2)$N&HU literal 17 UcmZSX+g@Tc(fO$n0|Yn#05M<$8UO$Q diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Category.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Category.java index c25d3fcd1..6048b61ea 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Category.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Category.java @@ -1,11 +1,14 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.annotation.Id; + public class Category { - private final long id; + @Id + private final Long id; private final String categoryName; private final String endPoint; - public Category(long id, String categoryName, String endPoint) { + public Category(Long id, String categoryName, String endPoint) { this.id = id; this.categoryName = categoryName; this.endPoint = endPoint; @@ -22,4 +25,13 @@ public String getCategoryName() { public String getEndPoint() { return endPoint; } + + @Override + public String toString() { + return "Category{" + + "id=" + id + + ", categoryName='" + categoryName + '\'' + + ", endPoint='" + endPoint + '\'' + + '}'; + } } diff --git a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java index a6c96c16b..95fceb06f 100644 --- a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java +++ b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java @@ -1,13 +1,53 @@ package com.codesquad.sidedish.SideDish; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.codesquad.sidedish.SideDish.domain.Category; +import com.codesquad.sidedish.SideDish.domain.CategoryRepository; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static org.assertj.core.api.Assertions.*; + +@Transactional @SpringBootTest class SideDishApplicationTests { + private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); + @Autowired + private CategoryRepository categoryRepository; + @Test - void contextLoads() { + @DisplayName("category 정보 테스트") + void readCategory() { + Long mainId = 1L; + Category main = categoryRepository.findById(mainId).get(); + logger.info("main {}", main.toString()); + + Long soupId = 2L; + Category soup = categoryRepository.findById(soupId).get(); + logger.info("soup {}", soup.toString()); + + Long sideId = 3L; + Category side = categoryRepository.findById(sideId).get(); + logger.info("side {}", side.toString()); + + checkNameAndEndPoint(main, "메인요리", "/main"); + checkNameAndEndPoint(soup, "국.찌개", "/soup"); + checkNameAndEndPoint(side, "반찬", "/side"); + } + + private void checkNameAndEndPoint(Category category, String name, String endPoint) { + assertThat(category.getCategoryName()).isEqualTo(name); + assertThat(category.getEndPoint()).isEqualTo(endPoint); } } From 01cdef4503c033d0fc8756e89b33c8b17f8e5092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Mon, 26 Apr 2021 16:22:44 +0900 Subject: [PATCH 03/18] =?UTF-8?q?[test]=20Softl=20Assertion=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SideDish/SideDishApplicationTests.java | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java index 95fceb06f..1d14e2ab7 100644 --- a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java +++ b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java @@ -1,53 +1,51 @@ package com.codesquad.sidedish.SideDish; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.codesquad.sidedish.SideDish.domain.Category; import com.codesquad.sidedish.SideDish.domain.CategoryRepository; -import org.junit.jupiter.api.AfterAll; +import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -import static org.assertj.core.api.Assertions.*; - @Transactional @SpringBootTest class SideDishApplicationTests { - private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); - @Autowired - private CategoryRepository categoryRepository; - - @Test - @DisplayName("category 정보 테스트") - void readCategory() { - Long mainId = 1L; - Category main = categoryRepository.findById(mainId).get(); - logger.info("main {}", main.toString()); - - Long soupId = 2L; - Category soup = categoryRepository.findById(soupId).get(); - logger.info("soup {}", soup.toString()); - - Long sideId = 3L; - Category side = categoryRepository.findById(sideId).get(); - logger.info("side {}", side.toString()); - - checkNameAndEndPoint(main, "메인요리", "/main"); - checkNameAndEndPoint(soup, "국.찌개", "/soup"); - checkNameAndEndPoint(side, "반찬", "/side"); - } - - private void checkNameAndEndPoint(Category category, String name, String endPoint) { - assertThat(category.getCategoryName()).isEqualTo(name); - assertThat(category.getEndPoint()).isEqualTo(endPoint); - } + private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); + @Autowired + private CategoryRepository categoryRepository; + + @Test + @DisplayName("category 정보 테스트") + void readCategory() { + Long mainId = 1L; + Category main = categoryRepository.findById(mainId).get(); + logger.info("main {}", main.toString()); + + Long soupId = 2L; + Category soup = categoryRepository.findById(soupId).get(); + logger.info("soup {}", soup.toString()); + + Long sideId = 3L; + Category side = categoryRepository.findById(sideId).get(); + logger.info("side {}", side.toString()); + + SoftAssertions softly = new SoftAssertions(); + checkNameAndEndPoint(softly, main, "메인요리", "/main"); + checkNameAndEndPoint(softly, soup, "국.찌개", "/soup"); + checkNameAndEndPoint(softly, side, "반찬", "/side"); + softly.assertAll(); + } + + private void checkNameAndEndPoint(SoftAssertions softly, Category category, String name, String endPoint) { + softly.assertThat(category.getCategoryName()).isEqualTo(name); + softly.assertThat(category.getEndPoint()).isEqualTo(endPoint); + } } From f8654dba23ba283630f0069e0cc92eb9a3f7cb5f Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Tue, 27 Apr 2021 05:46:29 +0900 Subject: [PATCH 04/18] =?UTF-8?q?feat:=20JDBC=20=EC=97=B0=EB=8F=99=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8,=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EB=B2=A0=EC=9D=B4=EC=8A=A4=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=82=BD=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gradle/6.8.3/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../sidedish/SideDish/domain/Dish.java | 218 ------------------ .../SideDish/domain/DishRepository.java | 11 - .../SideDish/domain/delivery/Delivery.java | 24 ++ .../domain/delivery/DeliveryRepository.java | 7 + .../domain/delivery/DishDelivery.java | 30 +++ .../sidedish/SideDish/domain/dish/Dish.java | 114 +++++++++ .../SideDish/domain/dish/DishRepository.java | 14 ++ .../SideDish/domain/image/DishImage.java | 30 +++ .../sidedish/SideDish/domain/image/Image.java | 35 +++ .../domain/image/ImageRepository.java | 9 + .../SideDish/domain/sale/DishSale.java | 30 +++ .../sidedish/SideDish/domain/sale/Sale.java | 36 +++ .../SideDish/domain/sale/SaleRepository.java | 7 + backend/src/main/resources/data.sql | 206 +++++++++++++++++ backend/src/main/resources/schema.sql | 89 ++++--- 17 files changed, 603 insertions(+), 257 deletions(-) delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java diff --git a/backend/.gradle/6.8.3/fileHashes/fileHashes.lock b/backend/.gradle/6.8.3/fileHashes/fileHashes.lock index 0745dda007f8f78f50e8a411fd0c449b4765bf3e..0fdd98f4d8655a524485b76bbdef20a793b09c7e 100644 GIT binary patch literal 17 UcmZQx;<;XitG1wm0SuUn0VuHpp#T5? literal 17 UcmZQx;<;XitG1wm0Sp-P04S&fng9R* diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 9d6d5cf511b956188f3bb69920457d35bf0db5c4..82b7cce020c51fedcbd67438737acb7ff07d3c78 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~j#A1pqP+1jqmY literal 17 UcmZSX+g@Tc(fO$n0|dMS05T2)$N&HU diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java deleted file mode 100644 index 27faf8853..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -public class Dish { - private final String detailHash; - private final String image; - private final String title; - private final String description; - private final List deliveryTypes; - private final int price; - private final int salePrice; - private final List badges; - - private final List thumbImages; - private final int point; - private final String deliveryInfo; - private final int deliveryFee; - private final List detailImages; - - private final long categoryId; - private final int quantity; - - // FIXME: 하드 코딩되었지만, AuditingEntityListener 로 자동화해야함 - private final LocalDateTime modifiedDateTime = LocalDateTime.of(2021, 4, 24, 21, 57); - - private Dish(Builder builder) { - this.detailHash = builder.detailHash; - this.image = builder.image; - this.deliveryTypes = builder.deliveryTypes; - this.title = builder.title; - this.description = builder.description; - this.price = builder.price; - this.salePrice = builder.salePrice; - this.badges = builder.badges; - - this.thumbImages = builder.thumbImages; - this.point = builder.point; - this.deliveryInfo = builder.deliveryInfo; - this.deliveryFee = builder.deliveryFee; - this.detailImages = builder.detailImages; - - this.categoryId = builder.categoryId; - this.quantity = builder.quantity; - } - - public static class Builder { - private String detailHash; - private String image; - private String title; - private String description; - private List deliveryTypes; - private int price; - private int salePrice; - private List badges; - - private List thumbImages; - private int point; - private String deliveryInfo; - private int deliveryFee; - private List detailImages; - - private long categoryId; - private int quantity; - - public Dish build() { - return new Dish(this); - } - - public Builder detailHash(String detailHash) { - this.detailHash = detailHash; - return this; - } - - public Builder image(String image) { - this.image = image; - return this; - } - - public Builder title(String title) { - this.title = title; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder deliveryTypes(List deliveryTypes) { - this.deliveryTypes = deliveryTypes; - return this; - } - - public Builder price(int price) { - this.price = price; - return this; - } - - public Builder salePrice(int salePrice) { - this.salePrice = salePrice; - return this; - } - - public Builder badges(List badges) { - this.badges = badges; - return this; - } - - - public Builder thumbImages(List thumbImages) { - this.thumbImages = thumbImages; - return this; - } - - public Builder point(int point) { - this.point = point; - return this; - } - - public Builder deliveryInfo(String deliveryInfo) { - this.deliveryInfo = deliveryInfo; - return this; - } - - public Builder deliveryFee(int deliveryFee) { - this.deliveryFee = deliveryFee; - return this; - } - - public Builder detailImages(List detailSection) { - this.detailImages = detailSection; - return this; - } - - public Builder categoryId(long categoryId) { - this.categoryId = categoryId; - return this; - } - - public Builder quantity(int quantity) { - this.quantity = quantity; - return this; - } - } - - - public String getDetailHash() { - return detailHash; - } - - public String getImage() { - return image; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public List getDeliveryTypes() { - return deliveryTypes; - } - - public int getPrice() { - return price; - } - - public int getSalePrice() { - return salePrice; - } - - public List getBadges() { - return badges; - } - - public List getThumbImages() { - return thumbImages; - } - - public int getPoint() { - return point; - } - - public String getDeliveryInfo() { - return deliveryInfo; - } - - public int getDeliveryFee() { - return deliveryFee; - } - - public List getDetailImages() { - return detailImages; - } - - - public long getCategoryId() { - return categoryId; - } - - public int getQuantity() { - return quantity; - } - - public boolean refreshable(long lastUpdated) { - LocalDateTime parsedDateTime = LocalDateTime.parse( - String.format("20%d", lastUpdated), - DateTimeFormatter.ofPattern("yyyyMMddHHmm") - ); - return modifiedDateTime.isAfter(parsedDateTime); - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java deleted file mode 100644 index de2dc039e..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface DishRepository extends CrudRepository { - List findAllByCategoryId(long categoryId); - - Dish findByDetailHash(String detailHash); -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java new file mode 100644 index 000000000..98644ac5b --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java @@ -0,0 +1,24 @@ +package com.codesquad.sidedish.SideDish.domain.delivery; + +import org.springframework.data.annotation.Id; + +public class Delivery { + + @Id + private Long id; + + private String deliveryType; + + public Delivery(String deliveryType) { + this.deliveryType = deliveryType; + } + + public Long getId() { + return id; + } + + public String getDeliveryType() { + return deliveryType; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java new file mode 100644 index 000000000..d89cf71e0 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java @@ -0,0 +1,7 @@ +package com.codesquad.sidedish.SideDish.domain.delivery; + +import org.springframework.data.repository.CrudRepository; + +public interface DeliveryRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java new file mode 100644 index 000000000..15641c0d2 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java @@ -0,0 +1,30 @@ +package com.codesquad.sidedish.SideDish.domain.delivery; + +import org.springframework.data.annotation.Id; + +public class DishDelivery { + + @Id + private Long id; + + private String dish; + private Long delivery; + + public DishDelivery(String dish, Long delivery) { + this.dish = dish; + this.delivery = delivery; + } + + public Long getId() { + return id; + } + + public String getDish() { + return dish; + } + + public Long getDelivery() { + return delivery; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java new file mode 100644 index 000000000..d0e1e389b --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java @@ -0,0 +1,114 @@ +package com.codesquad.sidedish.SideDish.domain.dish; + +import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; +import com.codesquad.sidedish.SideDish.domain.image.DishImage; +import com.codesquad.sidedish.SideDish.domain.sale.DishSale; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.time.LocalDateTime; +import java.util.HashSet; +import java.util.Set; + +public class Dish { + + private final String detailHash; + private final String image; + private final String title; + private final String description; + private final int price; + private final int salePrice; + private final int point; + private final String deliveryInfo; + private final int deliveryFee; + private final long categoryId; + private final int quantity; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") + private LocalDateTime currentDateTime; + + private Set dishSales = new HashSet<>(); + private Set dishDeliveries = new HashSet<>(); + private Set dishImages = new HashSet<>(); + + public Dish(String detailHash, String image, String title, String description, int price, int salePrice, int point, String deliveryInfo, int deliveryFee, long categoryId, int quantity) { + this.detailHash = detailHash; + this.image = image; + this.title = title; + this.description = description; + this.price = price; + this.salePrice = salePrice; + this.point = point; + this.deliveryInfo = deliveryInfo; + this.deliveryFee = deliveryFee; + this.categoryId = categoryId; + this.quantity = quantity; + this.currentDateTime = LocalDateTime.now(); + } + + public void addImage(DishImage... dishImages){ + for(DishImage dishImage: dishImages) { + this.dishImages.add(dishImage); + } + } + + public String getDetailHash() { + return detailHash; + } + + public String getImage() { + return image; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public int getPrice() { + return price; + } + + public int getSalePrice() { + return salePrice; + } + + public int getPoint() { + return point; + } + + public String getDeliveryInfo() { + return deliveryInfo; + } + + public int getDeliveryFee() { + return deliveryFee; + } + + public long getCategoryId() { + return categoryId; + } + + public int getQuantity() { + return quantity; + } + + public Set getDishImages() { + return dishImages; + } + + public Set getDishSales() { + return dishSales; + } + + public Set getDishDeliveries() { + return dishDeliveries; + } + + public LocalDateTime getCurrentDateTime() { + return currentDateTime; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java new file mode 100644 index 000000000..5af08717c --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java @@ -0,0 +1,14 @@ +package com.codesquad.sidedish.SideDish.domain.dish; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface DishRepository extends CrudRepository { +// @Query("SELECT detail_hash FROM dish WHERE DISH.CATEGORY_ID =:categoryId" + + List findAllByCategoryId(@Param("categoryId")Long categoryId); + + Dish findByDetailHash(String detailHash); +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java new file mode 100644 index 000000000..a3f92762d --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java @@ -0,0 +1,30 @@ +package com.codesquad.sidedish.SideDish.domain.image; + +import org.springframework.data.annotation.Id; + +public class DishImage { + @Id + private Long id; + + private String dish; + private Long image; + + public DishImage(String dish, Long image) { + this.dish = dish; + this.image = image; + } + + public Long getId() { + return id; + } + + public String getDish() { + return dish; + } + + public Long getImage() { + return image; + } + + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java new file mode 100644 index 000000000..67eee8ce3 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java @@ -0,0 +1,35 @@ +package com.codesquad.sidedish.SideDish.domain.image; + +import org.springframework.data.annotation.Id; + +public class Image { + + @Id + private Long id; + + private String imageUrl; + + private String type; + + protected Image() { + } + + public Image(String imageUrl, String type) { + this.imageUrl = imageUrl; + this.type = type; + } + + + public Long getId() { + return id; + } + + public String getImageUrl() { + return imageUrl; + } + + public String getType() { + return type; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java new file mode 100644 index 000000000..962f7b03c --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java @@ -0,0 +1,9 @@ +package com.codesquad.sidedish.SideDish.domain.image; + +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface ImageRepository extends CrudRepository { + List findImagesByType(String type); +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java new file mode 100644 index 000000000..390fc1899 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java @@ -0,0 +1,30 @@ +package com.codesquad.sidedish.SideDish.domain.sale; + +import org.springframework.data.annotation.Id; + +public class DishSale { + + @Id + private Long id; + + private String dish; + private Long sale; + + public DishSale(String dish, Long sale) { + this.dish = dish; + this.sale = sale; + } + + public Long getId() { + return id; + } + + public String getDish() { + return dish; + } + + public Long getSale() { + return sale; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java new file mode 100644 index 000000000..9ce6d6e53 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java @@ -0,0 +1,36 @@ +package com.codesquad.sidedish.SideDish.domain.sale; + +import org.springframework.data.annotation.Id; + +public class Sale { + + @Id + private Long id; + + private String badge; + private String saleType; + private int saleValue; + + public Sale(String badge, String saleType, int saleValue) { + this.badge = badge; + this.saleType = saleType; + this.saleValue = saleValue; + } + + public Long getId() { + return id; + } + + public String getBadge() { + return badge; + } + + public String getSaleType() { + return saleType; + } + + public int getSaleValue() { + return saleValue; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java new file mode 100644 index 000000000..fe43e6fa6 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java @@ -0,0 +1,7 @@ +package com.codesquad.sidedish.SideDish.domain.sale; + +import org.springframework.data.repository.CrudRepository; + +public interface SaleRepository extends CrudRepository { + +} diff --git a/backend/src/main/resources/data.sql b/backend/src/main/resources/data.sql index e783bb12f..93d70a4cc 100644 --- a/backend/src/main/resources/data.sql +++ b/backend/src/main/resources/data.sql @@ -4,3 +4,209 @@ VALUES (1, '메인요리', '/main'), (2, '국.찌개', '/soup'), (3, '반찬', '/side'); + + +INSERT INTO sidedish.dish + (detail_hash, image, title, description, price, sale_price,point, delivery_info, delivery_fee, category_id, quantity) +VALUES + ('HBDEF', 'http://public.codesquad.kr/jk/storeapp/data/2d3f99a9a35601f4e98837bc4d39b2c8.jpg', '[미노리키친] 규동 250g', '일본인의 소울푸드! 한국인도 좋아하는 소고기덮밥', 6000, 5200, 52,'서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HDF73', 'http://public.codesquad.kr/jk/storeapp/data/7674311a02ba7c88675f3186ddaeef9e.jpg', '[빅마마의밥친구] 아삭 고소한 연근고기조림 250g', '편식하는 아이도 좋아하는 건강한 연근조림', 5500, null, 55, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HF778', 'http://public.codesquad.kr/jk/storeapp/data/cad8eee316cf7151e07638aa57b32a9d.jpg', '[소중한식사] 골뱅이무침 195g', '매콤새콤달콤, 반찬으로도 안주로도 좋은', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HFB53', 'http://public.codesquad.kr/jk/storeapp/data/b6beada6b89af950289003d929936d9c.jpg', '[옹가솜씨] 꽁치간장조림 240g', '[옹가솜씨] 꽁치간장조림 240g', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H077F', 'http://public.codesquad.kr/jk/storeapp/data/0221110ead70dfd455e40703bbdd6252.jpg', '[마더앤찬] 코다리구이 320g', '큼지막하고 살집 많은 동태 한 마리로 만든 코다리구이입니다.', 7500, 6750, 67, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H4665', 'http://public.codesquad.kr/jk/storeapp/data/385f4106ac26f6e4fe7c640714f405a5.jpg', '[남도애꽃] 반건조 문어조림 120g', '씹을수록 감칠맛나는 문어살의 쫄깃함', 4600, null, 46, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H1AA9', 'http://public.codesquad.kr/jk/storeapp/data/2455226945d52f5aefd51f35d663bb16.jpg', '[마샐미디쉬] 매콤마늘쫑 해산물볶음 180g', '탱글탱글한 새우와 오징어를 마늘쫑과 함께 매콤하게 볶아냈어요.', 6900, 6210, 62, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HEDFB', 'http://public.codesquad.kr/jk/storeapp/data/bc3b777115e8377a48c7bd762fe5fdc9.jpg', '[빅마마의밥친구] 비빔오징어 150g', '달콤한 신야초발효액이 포인트!', 5000, null, 50, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + + ('H72C3', 'http://public.codesquad.kr/jk/storeapp/data/d1fccf125f0a78113d0e06cb888f2e74.jpg', '[수하동] 특곰탕 850g', '100% 한우양지로 끓여낸 70년전통의 서울식곰탕', 15000, 14200, 142, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HA6EE', 'http://public.codesquad.kr/jk/storeapp/data/c069bc32cb37727c59e1f0c2839311a0.jpg', '[빅마마의밥친구] 된장찌개 900g', '항아리에서 숙성시킨 집된장으로만 맛을내 짜지 않은 된장찌개', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H8CD0', 'http://public.codesquad.kr/jk/storeapp/data/f31fc3f5828c27ff60e4cf89a862d31c.jpg', '[탐나는밥상] 동태탕 1000g', '칼칼한 국물이 속 풀기에 딱 좋은 동태탕', 14000, null, 140, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HE2E9', 'http://public.codesquad.kr/jk/storeapp/data/6edbb16da52708e8533b85fbf743f882.jpg', '[국물닷컴] 치즈부대찌개 600g', '안주용 부대찌개와는 달라 밥말아먹기 딱 좋은', 4300, null, 43, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HAA47', 'http://public.codesquad.kr/jk/storeapp/data/892f3e7f043bfa7dbbcd58f88eecac36.jpg', '[집밥의완성] 스키야키 1.5kg (2~3인분)', '진한 풍미의 일본식 전골, 스키야키', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H3254', 'http://public.codesquad.kr/jk/storeapp/data/ae571e13d18fd4f0f40d685d2c8fe8f1.jpg', '[새로미부산어묵] 프리미엄 어묵탕세트', '밀가루 0% 프리미엄 어묵에 어묵스프까지 드려요!', 18000, 14400, 144, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H26C7', 'http://public.codesquad.kr/jk/storeapp/data/8fd330b5f5dbccbcbf4f5731e5e9e29b.jpg', '[모이세] 육개장 1팩(600g)', '제주3대해장국 맛집의 인기메뉴', 5000, 4400, 44, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HFFF9', 'http://public.codesquad.kr/jk/storeapp/data/2416b58044d49f0d3a24256f8e76163b.jpg', '[마더앤찬] 명란감자국 630ml', '간간한 저염명란과 고소한 감자가 조화로운 국이에요', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + + ('HBBCC', 'http://public.codesquad.kr/jk/storeapp/data/fdb0d5fcfb86e332505785225a6d9ade.jpg', '[마샐미디쉬] 유자소스 연근무침 250g', '향긋한 유자향과 아삭한 연근', 6500, null, 65, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H1939', 'http://public.codesquad.kr/jk/storeapp/data/e5646e5fc09a01a9243979b229e0572b.jpg', '[동네부엌] 쇠고기야채장조림 200g', '부드러운 고기부터 밥비벼먹기 딱좋은 국물까지', 7400, null, 74, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H8EA5', 'http://public.codesquad.kr/jk/storeapp/data/4cfd1954861ebd18b5b53e558a8e902e.jpg', '[소중한식사] 도라지초무침 150g', '새콤달콤 입맛 돋우는', 4000, null, 40, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H602F', 'http://public.codesquad.kr/jk/storeapp/data/422befe07f7e2860b9a83a8d7049ec2e.jpg', '[미노리키친] 일본식 우엉조림(킨피라고보) 80g', '한국식 우엉조림과는 다른 진한 감칠맛', 3300, null, 33, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + + ('H9F0B', 'http://public.codesquad.kr/jk/storeapp/data/d0b5d2be962947d9534e2140d1b34b2d.jpg', '[빅마마의밥친구] 갈치포무침 150g', '쉽게 접할수 없는 꼬순내가득 갈치포 무침', 7000, null, 70, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H0FC6', 'http://public.codesquad.kr/jk/storeapp/data/f6817349118d4c671da8dca9065649a9.jpg', '[마더앤찬] 명란치즈계란말이 230g', '아이반찬으로 최고 계란말이', 3870, null, 38, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HCCFE', 'http://public.codesquad.kr/jk/storeapp/data/757878b14ee5a8d5af905c154fc38f01.jpg', '[옹가솜씨] 달걀곤약조림 330g', '칼로리 부담 쭉쭉 내린', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HB9C1', 'http://public.codesquad.kr/jk/storeapp/data/043cf496f07899e7515f761e29d1ffa9.jpg', '[너의반찬] 미소된장 고추무침 200g', '고소한 양념 때문에 손이 자꾸 가요', 4500, null, 45, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5); + +INSERT INTO sidedish.image + (id, image_url, type) +VALUES + (1, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4cce011a4a352c22cd399a60271b4921.jpg', 'thumb'), + (2, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/6ef14155afc5b47e8c9efd762f7a6096.jpg', 'thumb'), + (3, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/8744504ff3bc315f901dca1f26fe63a1.jpg', 'thumb'), + (4, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/e30bd6de9340fc05db3cd1d1329b2c56.jpg', 'thumb'), + (5, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/9c2c53b40a11b79c90549a058c2da4b7.jpg', 'detail'), + (6, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/70b0c77d3ef5cdd6269588685bbefe43.jpg', 'detail'), + (7, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/72f1049b047f65f42a267d5bbd1e6204.jpg', 'detail'), + (8, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/768afd17faa8bf3461b8160ba0aa26bf.jpg', 'detail'), + (9, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/95816f09d3294641f2e0feacaa739991.jpg', 'detail'), + (10, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/2450219a4686d9d6d579fc04020929b4.jpg', 'detail'), + (11, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4971475295545ec336c9479fabb25364.jpg', 'detail'), + (12, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/a8c434715709fe855f3ea1554ec362b6.jpg', 'detail'), + (13, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/b2b3d0d2107ab91b16e0eb804cd84bc9.jpg', 'detail'), + (14, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/c0dd6887c9d9368604fc70d7fc3c4598.jpg', 'detail'), + + (15, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0f95f44ea8e2e7930321def493753a48.jpg', 'thumb'), + (16, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/2d408898494ac950d7d2cfd6c36d59c2.jpg', 'thumb'), + (17, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/62c8bb77facfc9c3be81f9bf45b27f2a.jpg', 'thumb'), + (18, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/f6d73afc0ebc1efa71eaea32e9d846f2.jpg', 'thumb'), + (19, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (20, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/5f73c5c80b62ef63c8a8eecefe32fc29.jpg', 'detail'), + (21, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (22, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0253cdebc4972fefd6b94458024fe765.jpg', 'detail'), + (23, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/3299da0677b50c8c519adc0335271c49.jpg', 'detail'), + (24, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0642265b65dcc2490ab164ff428cbfe2.jpg', 'detail'), + (25, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/695683493c1ae475a175475f50d3259f.jpg', 'detail'), + (26, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/c8f9bed4f5c07585b869e3d171904a93.jpg', 'detail'), + (27, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d2e3274c95c832bc9bfbcebbd548f61b.jpg', 'detail'), + (28, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d9e4fa00652483d74b46317d38159a2f.jpg', 'detail'), + (29, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d7799b67683128642453f9e2b4c8ce84.jpg', 'detail'), + + + (30, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/4e96f386d5a5c4459bc0ac6ffd0c1fce.jpg', 'thumb'), + (31, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/00327d0df92e29bad02e7387349bed53.jpg', 'thumb'), + (32, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/781fea32c56eb102429902a2f62cbaf3.jpg', 'thumb'), + (33, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/edd7a54096d6df1b8bc8b318cea0191c.jpg', 'detail'), + (34, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/fb8e6e21faa8284021c1b1c7a1ae1281.jpg', 'detail'), + (35, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/36a0566d2fb69a4bcea946727181836d.jpg', 'detail'), + + (36, 'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/2ad963a9f63d371826748c852a0025c3.jpg', 'thumb'), + (37,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/f945d8ac1dccc3f931bcaf35de5de582.jpg', 'thumb'), + (38,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/bacb0b8186371bfafbd92dbeec718e13.jpg', 'thumb'), + (39,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b96b02e9a956c6d5ad1e10eb14ba81e0.jpg', 'thumb'), + (40,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/3d67aabd2751620367e1d1ac3e3d7ef2.jpg', 'detail'), + (41,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/855b42b4e80162e6930f06aa80bd1272.jpg', 'detail'), + (42,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/1966de56cf138639d5d50d4bf2db8e72.jpg', 'detail'), + (43,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b3dd54082745d1188f3a6e582e7cd993.jpg', 'detail'), + (44,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/4a6fd1fd1116c14aa6aef5e6851ab6a9.jpg', 'detail'), + (45,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/7e12275d669102d0269278a7c91ab49d.jpg', 'detail'), + (46,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/ab34ea3755f59a21662266eb62b7bc4b.jpg', 'detail'), + (47,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b0a70ff59a3b5360b6246b507693c4d4.jpg', 'detail'), + (48,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/dc772923b4a2e053f1baf68fa28a48ee.jpg', 'detail'), + + (49, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c8c8045696b4692107ef28c8b445ca42.jpg', 'thumb'), + (50, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/edc6bae2e2663f05b4e8eb5a2b95d68f.jpg', 'thumb'), + (51, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c935f5913dc66b11ebceeef85485c438.jpg', 'thumb'), + (52, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/7c1e24867611394f04b37d05593e21ba.jpg', 'thumb'), + (53, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/670e7deefe1d84a4f4e058655fbd4d7c.jpg', 'detail'), + (54, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/1898cda038e92454395b8ffca8cd4393.jpg', 'detail'), + (55, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49516d302dad870fbdd75cf98a01eae4.jpg', 'detail'), + (56, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c1bb6fe4f72fcea27ea989ae48c61c86.jpg', 'detail'), + (57, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49afed8d3ec417b39ce8de456fc6661c.jpg', 'detail'), + (58, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/e62762e63f3e12dc2857a065badf1eea.jpg', 'detail'), + (59, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/31103ab946bff52b709ec6891e768c05.jpg', 'detail'), + (60, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/f84dc16f4f6d97661bd13d587a72d6b1.jpg', 'detail'), + (61, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/fd3f49614f731a0610a5409c0deb3c60.jpg', 'detail'), + + (62, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/43c38eeffa556554c9b06301eb3e85b2.jpg', 'thumb'), + (63, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/92f556b605c4a84813070d7214c4f336.jpg', 'thumb'), + (64, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/538b8ab021c7814aa4af860d94f81287.jpg', 'thumb'), + (65, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/adaef08ab0680b087096afa0f0070fad.jpg', 'thumb'), + (66, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/341b8605fa224ec1808c4f169097d170.jpg', 'detail'), + (67, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/0228d4cb660a3cca06952917bd024dcb.jpg', 'detail'), + (68, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e027227f61a93b6473e8c4bbd5c3de74.jpg', 'detail'), + (69, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/03ac0b09199421bb61727c667c2361f6.jpg', 'detail'), + (70, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/cbe4a3e12b7bdba5cf410e0e19dcf1ca.jpg', 'detail'), + (71,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/b58fa5791b67db106524b48442cb1c6a.jpg', 'detail'), + (72,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/82cfe0332f0e1c927a23b79f1d152430.jpg', 'detail'), + (73,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/390ca9ad5a574cbe7f3f6e26871f6690.jpg', 'detail'), + (74,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e113889a6120357c8e6196802a9f155b.jpg', 'detail'), + (75,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/967e8e1ef357e9722b796e2bcb09ba3d.jpg', 'detail'); + +INSERT INTO sidedish.dish_image + (dish, image) +values + ('HBDEF', 1),('HBDEF', 2),('HBDEF', 3),('HBDEF', 4),('HBDEF', 5),('HBDEF', 6),('HBDEF', 7),('HBDEF', 8),('HBDEF', 9),('HBDEF', 10),('HBDEF', 11),('HBDEF', 12),('HBDEF', 13),('HBDEF', 14), + ('HDF73', 15),('HDF73', 16),('HDF73', 17),('HDF73', 18),('HDF73', 19),('HDF73', 20),('HDF73', 21),('HDF73', 22),('HDF73', 23),('HDF73', 24),('HDF73', 25),('HDF73', 26),('HDF73', 27),('HDF73', 28),('HDF73', 29), + ('HF778', 1),('HF778', 2),('HF778', 3),('HF778', 4),('HF778', 5),('HF778', 6),('HF778', 7),('HF778', 8),('HF778', 9),('HF778', 10),('HF778', 11),('HF778', 12),('HF778', 13),('HF778', 14), + ('HFB53', 1),('HFB53', 2),('HFB53', 3),('HFB53', 4),('HFB53', 5),('HFB53', 6),('HFB53', 7),('HFB53', 8),('HFB53', 9),('HFB53', 10),('HFB53', 11),('HFB53', 12),('HFB53', 13),('HFB53', 14), + ('H077F', 1),('H077F', 2),('H077F', 3),('H077F', 4),('H077F', 5),('H077F', 6),('H077F', 7),('H077F', 8),('H077F', 9),('H077F', 10),('H077F', 11),('H077F', 12),('H077F', 13),('H077F', 14), + ('H4665', 15),('H4665', 16),('H4665', 17),('H4665', 18),('H4665', 19),('H4665', 20),('H4665', 21),('H4665', 22),('H4665', 23),('H4665', 24),('H4665', 25),('H4665', 26),('H4665', 27),('H4665', 28),('H4665', 29), + ('H1AA9', 15),('H1AA9', 16),('H1AA9', 17),('H1AA9', 18),('H1AA9', 19),('H1AA9', 20),('H1AA9', 21),('H1AA9', 22),('H1AA9', 23),('H1AA9', 24),('H1AA9', 25),('H1AA9', 26),('H1AA9', 27),('H1AA9', 28),('H1AA9', 29), + ('HEDFB', 15),('HEDFB', 16),('HEDFB', 17),('HEDFB', 18),('HEDFB', 19),('HEDFB', 20),('HEDFB', 21),('HEDFB', 22),('HEDFB', 23),('HEDFB', 24),('HEDFB', 25),('HEDFB', 26),('HEDFB', 27),('HEDFB', 28),('HEDFB', 29), + + ('H72C3', 30),('H72C3', 31),('H72C3', 32),('H72C3', 33),('H72C3', 34),('H72C3', 35), + ('HA6EE', 30),('HA6EE', 31),('HA6EE', 32),('HA6EE', 33),('HA6EE', 34),('HA6EE', 35), + ('H8CD0', 30),('H8CD0', 31),('H8CD0', 32),('H8CD0', 33),('H8CD0', 34),('H8CD0', 35), + ('HE2E9', 30),('HE2E9', 31),('HE2E9', 32),('HE2E9', 33),('HE2E9', 34),('HE2E9', 35), + ('HAA47', 30),('HAA47', 31),('HAA47', 32),('HAA47', 33),('HAA47', 34),('HAA47', 35), + ('H3254', 36),('H3254', 37),('H3254', 38),('H3254', 39),('H3254', 40),('H3254', 41),('H3254', 42),('H3254', 43),('H3254', 44),('H3254', 45),('H3254', 46),('H3254', 47),('H3254', 48), + ('H26C7', 36),('H26C7', 37),('H26C7', 38),('H26C7', 39),('H26C7', 40),('H26C7', 41),('H26C7', 42),('H26C7', 43),('H26C7', 44),('H26C7', 45),('H26C7', 46),('H26C7', 47),('H26C7', 48), + ('HFFF9', 36),('HFFF9', 37),('HFFF9', 38),('HFFF9', 39),('HFFF9', 40),('HFFF9', 41),('HFFF9', 42),('HFFF9', 43),('HFFF9', 44),('HFFF9', 45),('HFFF9', 46),('HFFF9', 47),('HFFF9', 48), + + ('HBBCC', 49),('HBBCC', 50),('HBBCC', 51),('HBBCC', 52),('HBBCC', 53),('HBBCC', 54),('HBBCC', 55),('HBBCC', 56),('HBBCC', 57),('HBBCC', 58),('HBBCC', 59),('HBBCC', 60),('HBBCC', 61), + ('H1939', 49),('H1939', 50),('H1939', 51),('H1939', 52),('H1939', 53),('H1939', 54),('H1939', 55),('H1939', 56),('H1939', 57),('H1939', 58),('H1939', 59),('H1939', 60),('H1939', 61), + ('H8EA5', 49),('H8EA5', 50),('H8EA5', 51),('H8EA5', 52),('H8EA5', 53),('H8EA5', 54),('H8EA5', 55),('H8EA5', 56),('H8EA5', 57),('H8EA5', 58),('H8EA5', 59),('H8EA5', 60),('H8EA5', 61), + ('H602F', 49),('H602F', 50),('H602F', 51),('H602F', 52),('H602F', 53),('H602F', 54),('H602F', 55),('H602F', 56),('H602F', 57),('H602F', 58),('H602F', 59),('H602F', 60),('H602F', 61), + ('H9F0B', 62),('H9F0B', 63),('H9F0B', 64),('H9F0B', 65),('H9F0B', 66),('H9F0B', 67),('H9F0B', 68),('H9F0B', 69),('H9F0B', 70),('H9F0B', 71),('H9F0B', 72),('H9F0B', 73),('H9F0B', 74),('H9F0B', 75), + ('H0FC6', 62),('H0FC6', 63),('H0FC6', 64),('H0FC6', 65),('H0FC6', 66),('H0FC6', 67),('H0FC6', 68),('H0FC6', 69),('H0FC6', 70),('H0FC6', 71),('H0FC6', 72),('H0FC6', 73),('H0FC6', 74),('H0FC6', 75), + ('HCCFE', 62),('HCCFE', 63),('HCCFE', 64),('HCCFE', 65),('HCCFE', 66),('HCCFE', 67),('HCCFE', 68),('HCCFE', 69),('HCCFE', 70),('HCCFE', 71),('HCCFE', 72),('HCCFE', 73),('HCCFE', 74),('HCCFE', 75), + ('HB9C1', 62),('HB9C1', 63),('HB9C1', 64),('HB9C1', 65),('HB9C1', 66),('HB9C1', 67),('HB9C1', 68),('HB9C1', 69),('HB9C1', 70),('HB9C1', 71),('HB9C1', 72),('HB9C1', 73),('HB9C1', 74),('HB9C1', 75); + +INSERT INTO sidedish.sale + (id, badge, sale_type, sale_value) +VALUES + (1, '이벤트특가', 'percentage', 10), + (2, '런칭특가', 'minus', 1000); + +INSERT INTO sidedish.dish_sale + (dish, sale) +VALUES + ('HBDEF', 1), + ('HF778', 1), + ('H077F', 1), + ('H1AA9', 1), + ('H72C3', 1), + ('H72C3', 2), + ('H3254', 1), + ('H3254', 2), + ('H26C7', 1), + ('H26C7', 2), + ('HFFF9', 1), + ('HFFF9', 2); + +INSERT INTO sidedish.delivery + (id, delivery_type) +VALUES + (1, '새벽배송'), + (2, '전국택배'); + +INSERT INTO sidedish.dish_delivery + (dish, delivery) +VALUES + ('HBDEF', 1), ('HBDEF', 2), + ('HDF73', 1), ('HDF73', 2), + ('HF778', 1), ('HF778', 2), + ('HFB53', 1),('HFB53', 2), + ('H077F', 1),('H077F', 2), + ('H4665', 1),('H4665', 2), + ('H1AA9', 1),('H1AA9', 2), + ('HEDFB', 1),('HEDFB', 2), + ('H72C3', 1),('H72C3', 2), + ('HA6EE', 1),('HA6EE', 2), + ('H8CD0', 1),('H8CD0', 2), + ('HE2E9', 1),('HE2E9', 2), + ('HAA47', 1),('HAA47', 2), + ('H3254', 1),('H3254', 2), + ('H26C7', 1),('H26C7', 2), + ('HFFF9', 1),('HFFF9', 2), + ('HBBCC', 1),('HBBCC', 2), + ('H1939', 1),('H1939', 2), + ('H8EA5', 1),('H8EA5', 2), + ('H602F', 1),('H602F', 2), + ('H9F0B', 1),('H9F0B', 2), + ('H0FC6', 1),('H0FC6', 2), + ('HCCFE', 1),('HCCFE', 2), + ('HB9C1', 1),('HB9C1', 2); + + + diff --git a/backend/src/main/resources/schema.sql b/backend/src/main/resources/schema.sql index 48536fe6d..336da369a 100644 --- a/backend/src/main/resources/schema.sql +++ b/backend/src/main/resources/schema.sql @@ -18,17 +18,7 @@ DROP SCHEMA IF EXISTS `sidedish` ; CREATE SCHEMA IF NOT EXISTS `sidedish` DEFAULT CHARACTER SET utf8 ; USE `sidedish` ; --- ----------------------------------------------------- --- Table `sidedish`.`delivery` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `sidedish`.`delivery` ; -CREATE TABLE IF NOT EXISTS `sidedish`.`delivery` ( - `id` INT(11) NOT NULL, - `type` VARCHAR(45) NOT NULL, - PRIMARY KEY (`id`)) - ENGINE = InnoDB - DEFAULT CHARACTER SET = utf8; -- ----------------------------------------------------- @@ -51,31 +41,49 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`category` ( DROP TABLE IF EXISTS `sidedish`.`dish` ; CREATE TABLE IF NOT EXISTS `sidedish`.`dish` ( - `detail_hash` VARCHAR(50) NOT NULL, - `image` VARCHAR(100) NOT NULL, - `alt` VARCHAR(50) NOT NULL, - `title` VARCHAR(50) NOT NULL, - `description` VARCHAR(100) NOT NULL, - `n_price` VARCHAR(45) NOT NULL, - `menu_id` INT(11) NOT NULL, + `detail_hash` VARCHAR(50), + `image` VARCHAR(100), + `title` VARCHAR(50), + `description` VARCHAR(100), + `price` INT(11), + `sale_price` INT(11), + `point` INT(11), + `delivery_info` VARCHAR(50), + `delivery_fee` INT(11), + `category_id` INT(11), + `quantity` INT(11), + + PRIMARY KEY (`detail_hash`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; - -- ----------------------------------------------------- --- Table `sidedish`.`dish_delivery` +-- Table `sidedish`.`delivery` -- ----------------------------------------------------- -DROP TABLE IF EXISTS `sidedish`.`dish_delivery` ; +DROP TABLE IF EXISTS `sidedish`.`delivery` ; -CREATE TABLE IF NOT EXISTS `sidedish`.`dish_delivery` ( +CREATE TABLE IF NOT EXISTS `sidedish`.`delivery` ( `id` INT(11) NOT NULL, - `dish_detail_hash` VARCHAR(50) NOT NULL, - `delivery_id` INT(11) NOT NULL, + `delivery_type` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; +-- ----------------------------------------------------- +-- Table `sidedish`.`dish_delivery` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish_delivery` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_delivery`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `delivery` INT, + CONSTRAINT dish_delivery_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_delivery_delivery_foreign_key FOREIGN KEY (`delivery`) REFERENCES `delivery` (id) +); + + -- ----------------------------------------------------- -- Table `sidedish`.`sale` @@ -86,7 +94,7 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`sale` ( `id` INT(11) NOT NULL, `badge` VARCHAR(45) NOT NULL, `sale_type` VARCHAR(45) NOT NULL, - `sale_vlaue` INT(11) NOT NULL, + `sale_value` INT(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; @@ -97,15 +105,40 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`sale` ( -- ----------------------------------------------------- DROP TABLE IF EXISTS `sidedish`.`dish_sale` ; -CREATE TABLE IF NOT EXISTS `sidedish`.`dish_sale` ( - `id` INT(11) NOT NULL, - `dish_detail_hash` VARCHAR(50) NOT NULL, - `sale_id` INT(11) NOT NULL, +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_sale`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `sale` INT, + CONSTRAINT dish_sale_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_sale_sale_foreign_key FOREIGN KEY (`sale`) REFERENCES `sale` (id) +); + + +DROP TABLE IF EXISTS `sidedish`.`image` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`image` ( + `id` INT(11) AUTO_INCREMENT NOT NULL, + `image_url` VARCHAR(100) NOT NULL, + `type` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; +-- ----------------------------------------------------- +-- Table `sidedish`.`dish_sale` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish_image` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_image`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `image` INT, + CONSTRAINT dish_image_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_image_image_foreign_key FOREIGN KEY (`image`) REFERENCES `image` (id) +); + + SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; From 5de75e12eebcd443cf599e8fe0d2c37fedfa7cdf Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Tue, 27 Apr 2021 09:55:03 +0900 Subject: [PATCH 05/18] =?UTF-8?q?feat:=20dish=20table=20currentDateTime=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/schema.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/main/resources/schema.sql b/backend/src/main/resources/schema.sql index 336da369a..1683f6410 100644 --- a/backend/src/main/resources/schema.sql +++ b/backend/src/main/resources/schema.sql @@ -52,8 +52,7 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`dish` ( `delivery_fee` INT(11), `category_id` INT(11), `quantity` INT(11), - - + `current_date_time` TIMESTAMP, PRIMARY KEY (`detail_hash`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; From 42f75afe34a991223c1ede6bc2ab1d4d63e0501e Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Wed, 28 Apr 2021 02:45:42 +0900 Subject: [PATCH 06/18] =?UTF-8?q?feat:=20image,=20sale,=20delivery?= =?UTF-8?q?=EC=97=90=20set=EC=9C=BC=EB=A1=9C=20=EB=A7=A4=ED=95=91=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SideDish/domain/delivery/Delivery.java | 13 +++ .../domain/delivery/DishDelivery.java | 2 + .../sidedish/SideDish/domain/dish/Dish.java | 22 +++++ .../SideDish/domain/dish/DishRepository.java | 6 ++ .../SideDish/domain/image/DishImage.java | 2 + .../sidedish/SideDish/domain/image/Image.java | 9 ++ .../SideDish/domain/sale/DishSale.java | 2 + .../sidedish/SideDish/domain/sale/Sale.java | 13 +++ .../SideDish/SideDishApplicationTests.java | 97 +++++++++++++------ 9 files changed, 137 insertions(+), 29 deletions(-) diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java index 98644ac5b..72e7108e9 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java @@ -2,6 +2,9 @@ import org.springframework.data.annotation.Id; +import java.util.HashSet; +import java.util.Set; + public class Delivery { @Id @@ -9,6 +12,12 @@ public class Delivery { private String deliveryType; + private Set dishDeliveries = new HashSet<>(); + + protected Delivery() { + + } + public Delivery(String deliveryType) { this.deliveryType = deliveryType; } @@ -21,4 +30,8 @@ public String getDeliveryType() { return deliveryType; } + public Set getDishDeliveries() { + return dishDeliveries; + } + } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java index 15641c0d2..3307fbe54 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.domain.delivery; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; public class DishDelivery { @@ -8,6 +9,7 @@ public class DishDelivery { private Long id; private String dish; + private Long delivery; public DishDelivery(String dish, Long delivery) { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java index d0e1e389b..6e352116b 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java @@ -4,6 +4,7 @@ import com.codesquad.sidedish.SideDish.domain.image.DishImage; import com.codesquad.sidedish.SideDish.domain.sale.DishSale; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; import java.time.LocalDateTime; import java.util.HashSet; @@ -111,4 +112,25 @@ public LocalDateTime getCurrentDateTime() { return currentDateTime; } + @Override + public String toString() { + return "Dish{" + + "detailHash='" + detailHash + '\'' + + ", image='" + image + '\'' + + ", title='" + title + '\'' + + ", description='" + description + '\'' + + ", price=" + price + + ", salePrice=" + salePrice + + ", point=" + point + + ", deliveryInfo='" + deliveryInfo + '\'' + + ", deliveryFee=" + deliveryFee + + ", categoryId=" + categoryId + + ", quantity=" + quantity + + ", currentDateTime=" + currentDateTime + +// ", dishSales=" + dishSales + +// ", dishDeliveries=" + dishDeliveries + +// ", dishImages=" + dishImages + + '}'; + } + } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java index 5af08717c..b6ab2d65b 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.domain.dish; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; @@ -8,7 +9,12 @@ public interface DishRepository extends CrudRepository { // @Query("SELECT detail_hash FROM dish WHERE DISH.CATEGORY_ID =:categoryId" + @Query("select * from DISH where dish.category_id = :categoryId") List findAllByCategoryId(@Param("categoryId")Long categoryId); + @Query("SELECT * FROM DISH where dish.detail_hash =:detailHash") Dish findByDetailHash(String detailHash); + + @Query("select count(*) from DISH where dish.category_id = :categoryId") + int countDishforCategoryId(Long categoryId); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java index a3f92762d..94deec0bd 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.domain.image; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; public class DishImage { @@ -7,6 +8,7 @@ public class DishImage { private Long id; private String dish; + private Long image; public DishImage(String dish, Long image) { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java index 67eee8ce3..a13dcaeec 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java @@ -2,6 +2,9 @@ import org.springframework.data.annotation.Id; +import java.util.HashSet; +import java.util.Set; + public class Image { @Id @@ -11,6 +14,8 @@ public class Image { private String type; + private Set dishImages = new HashSet<>(); + protected Image() { } @@ -32,4 +37,8 @@ public String getType() { return type; } + public Set getDishImages() { + return dishImages; + } + } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java index 390fc1899..43a02b810 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.domain.sale; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; public class DishSale { @@ -8,6 +9,7 @@ public class DishSale { private Long id; private String dish; + private Long sale; public DishSale(String dish, Long sale) { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java index 9ce6d6e53..13560fb0a 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java @@ -2,6 +2,9 @@ import org.springframework.data.annotation.Id; +import java.util.HashSet; +import java.util.Set; + public class Sale { @Id @@ -11,6 +14,12 @@ public class Sale { private String saleType; private int saleValue; + private Set dishSales = new HashSet<>(); + + protected Sale(){ + + } + public Sale(String badge, String saleType, int saleValue) { this.badge = badge; this.saleType = saleType; @@ -33,4 +42,8 @@ public int getSaleValue() { return saleValue; } + public Set getDishSales() { + return dishSales; + } + } diff --git a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java index 95fceb06f..126e718c8 100644 --- a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java +++ b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java @@ -1,6 +1,11 @@ package com.codesquad.sidedish.SideDish; +import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; +import com.codesquad.sidedish.SideDish.domain.dish.DishRepository; +import com.codesquad.sidedish.SideDish.domain.image.DishImage; +import com.codesquad.sidedish.SideDish.domain.sale.DishSale; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.codesquad.sidedish.SideDish.domain.Category; @@ -13,41 +18,75 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Set; import static org.assertj.core.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; -@Transactional @SpringBootTest class SideDishApplicationTests { - private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); - @Autowired - private CategoryRepository categoryRepository; - - @Test - @DisplayName("category 정보 테스트") - void readCategory() { - Long mainId = 1L; - Category main = categoryRepository.findById(mainId).get(); - logger.info("main {}", main.toString()); - - Long soupId = 2L; - Category soup = categoryRepository.findById(soupId).get(); - logger.info("soup {}", soup.toString()); - - Long sideId = 3L; - Category side = categoryRepository.findById(sideId).get(); - logger.info("side {}", side.toString()); - - checkNameAndEndPoint(main, "메인요리", "/main"); - checkNameAndEndPoint(soup, "국.찌개", "/soup"); - checkNameAndEndPoint(side, "반찬", "/side"); - } - - private void checkNameAndEndPoint(Category category, String name, String endPoint) { - assertThat(category.getCategoryName()).isEqualTo(name); - assertThat(category.getEndPoint()).isEqualTo(endPoint); - } + private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); + @Autowired + private CategoryRepository categoryRepository; + + @Test + @DisplayName("category 정보 테스트") + void readCategory() { + Long mainId = 1L; + Category main = categoryRepository.findById(mainId).get(); + logger.info("main {}", main.toString()); + + Long soupId = 2L; + Category soup = categoryRepository.findById(soupId).get(); + logger.info("soup {}", soup.toString()); + + Long sideId = 3L; + Category side = categoryRepository.findById(sideId).get(); + logger.info("side {}", side.toString()); + + checkNameAndEndPoint(main, "메인요리", "/main"); + checkNameAndEndPoint(soup, "국.찌개", "/soup"); + checkNameAndEndPoint(side, "반찬", "/side"); + } + + private void checkNameAndEndPoint(Category category, String name, String endPoint) { + assertThat(category.getCategoryName()).isEqualTo(name); + assertThat(category.getEndPoint()).isEqualTo(endPoint); + } + + @Autowired + private DishRepository dishRepository; + + @Test + @DisplayName("category 별로 생성된 dish의 개수 확인") + void countDish() { +// String hash1 = "HBDEF"; +// Dish dish1 = dishRepository.findByDetailHash(hash1); +// System.out.println(dish1.getCategoryId()); +// +// List mains = dishRepository.findAllByCategoryId(1L); +// System.out.println(mains.size()); + assertAll( + () -> assertEquals(8, dishRepository.countDishforCategoryId(1L)), + () -> assertEquals(8, dishRepository.countDishforCategoryId(2L)), + () -> assertEquals(8, dishRepository.countDishforCategoryId(3L)) + ); + } + + @Test + @DisplayName("dish 불러오기") + void readDish() { + Dish dish = dishRepository.findByDetailHash("HBBCC"); +// Set images = dish.getDishImages(); +// Set dishDeliveries = dish.getDishDeliveries(); +// Set dishSales = dish.getDishSales(); +// logger.info("images {}:", images); + + + + } } From f41a420f1bd9508ba9e41475c24fe78445586820 Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Wed, 28 Apr 2021 18:57:14 +0900 Subject: [PATCH 07/18] feat: create DTO --- .../SideDish/controller/DishController.java | 94 ++++++++++++------- .../domain/delivery/DishDelivery.java | 5 +- .../sidedish/SideDish/domain/dish/Dish.java | 3 + .../SideDish/domain/dish/DishRepository.java | 6 +- .../SideDish/domain/image/DishImage.java | 5 +- .../SideDish/domain/sale/DishSale.java | 5 +- .../sidedish/SideDish/domain/sale/Sale.java | 3 - .../sidedish/SideDish/dto/DeliveryDto.java | 24 +++++ .../sidedish/SideDish/dto/DishDetailDto.java | 64 ++----------- .../sidedish/SideDish/dto/DishDto.java | 74 +++++++-------- .../sidedish/SideDish/dto/ImageDto.java | 28 ++++++ .../sidedish/SideDish/dto/SaleDto.java | 35 +++++++ .../SideDish/service/DishService.java | 72 ++++++++------ .../src/main/resources/application.properties | 5 + 14 files changed, 257 insertions(+), 166 deletions(-) create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java index 72666101c..be88cb1b0 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.controller; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; import com.codesquad.sidedish.SideDish.dto.*; import com.codesquad.sidedish.SideDish.service.CategoryService; import com.codesquad.sidedish.SideDish.service.DishService; @@ -9,7 +10,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -32,45 +32,69 @@ public ResponseEntity> getCategories() { return ResponseEntity.ok().body(categories); } - @GetMapping("/detail/{detailHash}") - @ApiOperation(value = "요리 상세", notes = "요리의 상세 정보를 반환합니다.") - public ResponseEntity getDetail(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { - DishDetailDto dishDetailDto = dishService.getDetail(detailHash); - return ResponseEntity.ok().body(dishDetailDto); - } - - @GetMapping("/detail/{detailHash}/refreshable") - @ApiOperation(value = "요리 상세 갱신", notes = "요리의 상세 정보를 갱신할 필요가 있는지 여부를 반환합니다.") - public ResponseEntity getDetailRefreshable(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @ApiParam("프론트에서 마지막으로 업데이트 한 날짜. 데이터 형식: yyMMddhhmm") @RequestParam("lastUpdated") int lastUpdated) { - RefreshDto refreshDto = dishService.getDetailRefreshable(detailHash, lastUpdated); - return ResponseEntity.ok().body(refreshDto); - } - - @GetMapping("/detail/{detailHash}/quantity") - @ApiOperation(value = "요리 수량", notes = "요리의 주문 가능한 수량을 반환합니다.") - public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { - QuantityDto quantityDto = dishService.getDetailQuantity(detailHash); - return ResponseEntity.ok().body(quantityDto); - } - +// @GetMapping("/detail/{detailHash}") +// @ApiOperation(value = "요리 상세", notes = "요리의 상세 정보를 반환합니다.") +// public ResponseEntity getDetail(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { +// DishDetailDto dishDetailDto = dishService.getDetail(detailHash); +// return ResponseEntity.ok().body(dishDetailDto); +// } +// +// @GetMapping("/detail/{detailHash}/refreshable") +// @ApiOperation(value = "요리 상세 갱신", notes = "요리의 상세 정보를 갱신할 필요가 있는지 여부를 반환합니다.") +// public ResponseEntity getDetailRefreshable(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @ApiParam("프론트에서 마지막으로 업데이트 한 날짜. 데이터 형식: yyMMddhhmm") @RequestParam("lastUpdated") int lastUpdated) { +// RefreshDto refreshDto = dishService.getDetailRefreshable(detailHash, lastUpdated); +// return ResponseEntity.ok().body(refreshDto); +// } +// +// @GetMapping("/detail/{detailHash}/quantity") +// @ApiOperation(value = "요리 수량", notes = "요리의 주문 가능한 수량을 반환합니다.") +// public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { +// QuantityDto quantityDto = dishService.getDetailQuantity(detailHash); +// return ResponseEntity.ok().body(quantityDto); +// } +// @GetMapping("/main") @ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") public ResponseEntity> getMainList() { - List dishes = dishService.getList(1); + List dishes = dishService.getList(1L); return ResponseEntity.ok().body(dishes); } +// +// @GetMapping("/side") +// @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") +// public ResponseEntity> getSideList() { +// List dishes = dishService.getList(3); +// return ResponseEntity.ok().body(dishes); +// } +// +// @GetMapping("/soup") +// @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") +// public ResponseEntity> getSoupList() { +// List dishes = dishService.getList(2); +// return ResponseEntity.ok().body(dishes); +// } + +// @GetMapping("/main") +// @ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") +// public ResponseEntity> getMainList() { +// List dishes = dishService.getList(1L); +// return ResponseEntity.ok().body(dishes); +// } +// +// @GetMapping("/side") +// @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") +// public ResponseEntity> getSideList() { +// List dishes = dishService.getList(3L); +// return ResponseEntity.ok().body(dishes); +// } +// +// @GetMapping("/soup") +// @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") +// public ResponseEntity> getSoupList() { +// List dishes = dishService.getList(2L); +// return ResponseEntity.ok().body(dishes); +// } +// - @GetMapping("/side") - @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") - public ResponseEntity> getSideList() { - List dishes = dishService.getList(3); - return ResponseEntity.ok().body(dishes); - } - @GetMapping("/soup") - @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") - public ResponseEntity> getSoupList() { - List dishes = dishService.getList(2); - return ResponseEntity.ok().body(dishes); - } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java index 3307fbe54..1e6b7df82 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.PersistenceConstructor; public class DishDelivery { @@ -12,8 +13,8 @@ public class DishDelivery { private Long delivery; - public DishDelivery(String dish, Long delivery) { - this.dish = dish; + @PersistenceConstructor + public DishDelivery(Long delivery) { this.delivery = delivery; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java index 6e352116b..711ca7972 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java @@ -3,13 +3,16 @@ import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; import com.codesquad.sidedish.SideDish.domain.image.DishImage; import com.codesquad.sidedish.SideDish.domain.sale.DishSale; +import com.codesquad.sidedish.SideDish.dto.SaleDto; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.data.relational.core.mapping.Table; import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; +@Table("DISH") public class Dish { private final String detailHash; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java index b6ab2d65b..0baadda4d 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java @@ -9,10 +9,10 @@ public interface DishRepository extends CrudRepository { // @Query("SELECT detail_hash FROM dish WHERE DISH.CATEGORY_ID =:categoryId" - @Query("select * from DISH where dish.category_id = :categoryId") - List findAllByCategoryId(@Param("categoryId")Long categoryId); - @Query("SELECT * FROM DISH where dish.detail_hash =:detailHash") + + List findAllByCategoryId(Long categoryId); + Dish findByDetailHash(String detailHash); @Query("select count(*) from DISH where dish.category_id = :categoryId") diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java index 94deec0bd..eeda0b750 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.PersistenceConstructor; public class DishImage { @Id @@ -11,8 +12,8 @@ public class DishImage { private Long image; - public DishImage(String dish, Long image) { - this.dish = dish; + @PersistenceConstructor + public DishImage(Long image) { this.image = image; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java index 43a02b810..a6ada21fd 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.PersistenceConstructor; public class DishSale { @@ -12,8 +13,8 @@ public class DishSale { private Long sale; - public DishSale(String dish, Long sale) { - this.dish = dish; + @PersistenceConstructor + public DishSale(Long sale) { this.sale = sale; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java index 13560fb0a..783ed05f0 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java @@ -16,9 +16,6 @@ public class Sale { private Set dishSales = new HashSet<>(); - protected Sale(){ - - } public Sale(String badge, String saleType, int saleValue) { this.badge = badge; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java new file mode 100644 index 000000000..ccc97bd96 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java @@ -0,0 +1,24 @@ +package com.codesquad.sidedish.SideDish.dto; + +import com.codesquad.sidedish.SideDish.domain.delivery.Delivery; + +public class DeliveryDto { + + private Long id; + private String deliveryType; + + public DeliveryDto(Delivery delivery) { + this.id = delivery.getId(); + this.deliveryType = delivery.getDeliveryType(); + } + + public Long getId() { + return id; + } + + public String getDeliveryType() { + return deliveryType; + } + + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java index 5a0ec4c05..e528c3326 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java @@ -1,8 +1,10 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; +import com.codesquad.sidedish.SideDish.domain.image.Image; import java.util.List; +import java.util.stream.Collectors; public class DishDetailDto { private final List thumbImages; @@ -11,60 +13,12 @@ public class DishDetailDto { private int deliveryFee; private final List detailImages; - private DishDetailDto(Builder builder) { - this.thumbImages = builder.thumbImages; - this.point = builder.point; - this.deliveryInfo = builder.deliveryInfo; - this.deliveryFee = builder.deliveryFee; - this.detailImages = builder.detailImages; - } - - public static DishDetailDto from(Dish dish) { - return new Builder() - .thumbImages(dish.getThumbImages()) - .point(dish.getPoint()) - .deliveryInfo(dish.getDeliveryInfo()) - .deliveryFee(dish.getDeliveryFee()) - .detailImages(dish.getDetailImages()) - .build(); - } - - private static class Builder { - private List thumbImages; - private int point; - private String deliveryInfo; - private int deliveryFee; - private List detailImages; - - public DishDetailDto build() { - return new DishDetailDto(this); - } - - - public Builder thumbImages(List thumbImages) { - this.thumbImages = thumbImages; - return this; - } - - public Builder point(int point) { - this.point = point; - return this; - } - - public Builder deliveryInfo(String deliveryInfo) { - this.deliveryInfo = deliveryInfo; - return this; - } - - public Builder deliveryFee(int deliveryFee) { - this.deliveryFee = deliveryFee; - return this; - } - - public Builder detailImages(List detailSection) { - this.detailImages = detailSection; - return this; - } + public DishDetailDto(Dish dish, List thumbImages, List detailImages) { + this.thumbImages = thumbImages.stream().map(Image::getImageUrl).collect(Collectors.toList()); + this.point = dish.getPoint(); + this.deliveryInfo = dish.getDeliveryInfo(); + this.deliveryFee = dish.getDeliveryFee(); + this.detailImages = detailImages.stream().map(Image::getImageUrl).collect(Collectors.toList()); } public List getThumbImages() { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java index ccc4b400a..cf7bea0f6 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java @@ -1,29 +1,27 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; +import com.codesquad.sidedish.SideDish.domain.sale.DishSale; +import com.codesquad.sidedish.SideDish.domain.sale.Sale; +import javafx.util.Builder; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; public class DishDto { private final String detailHash; private final String image; private final String title; private final String description; - private final List deliveryTypes; private final int price; private final int salePrice; - private final List badges; - private DishDto(Builder builder) { - this.detailHash = builder.detailHash; - this.image = builder.image; - this.deliveryTypes = builder.deliveryTypes; - this.title = builder.title; - this.description = builder.description; - this.price = builder.price; - this.salePrice = builder.salePrice; - this.badges = builder.badges; - } + + private Set badgeList; + public static DishDto from(Dish dish) { return new Builder() @@ -31,28 +29,38 @@ public static DishDto from(Dish dish) { .image(dish.getImage()) .title(dish.getTitle()) .description(dish.getDescription()) - .deliveryTypes(dish.getDeliveryTypes()) .price(dish.getPrice()) .salePrice(dish.getSalePrice()) - .badges(dish.getBadges()) + .badgeList(dish.getDishSales().stream() + .map(dishSale -> new SaleDto(new Sale("badge", "saleType", 0))) // TODO: 가라 데이터를 정상 + .collect(Collectors.toSet())) .build(); } + public DishDto(Builder builder) { + this.detailHash = builder.detailHash; + this.image = builder.image; + this.title = builder.title; + this.description = builder.description; + this.price = builder.price; + this.salePrice = builder.salePrice; + this.badgeList = builder.badgeList; + } + public static class Builder { - private String detailHash; - private String image; - private String title; - private String description; - private List deliveryTypes; - private int price; - private int salePrice; - private List badges; + private String detailHash; + private String image; + private String title; + private String description; + private int price; + private int salePrice; + + private Set badgeList; public DishDto build() { return new DishDto(this); } - public Builder detailHash(String detailHash) { this.detailHash = detailHash; return this; @@ -73,11 +81,6 @@ public Builder description(String description) { return this; } - public Builder deliveryTypes(List deliveryTypes) { - this.deliveryTypes = deliveryTypes; - return this; - } - public Builder price(int price) { this.price = price; return this; @@ -88,10 +91,11 @@ public Builder salePrice(int salePrice) { return this; } - public Builder badges(List badges) { - this.badges = badges; + public Builder badgeList(Set badgeList) { + this.badgeList = badgeList; return this; } + } public String getDetailHash() { @@ -102,10 +106,6 @@ public String getImage() { return image; } - public List getDeliveryTypes() { - return deliveryTypes; - } - public String getTitle() { return title; } @@ -122,7 +122,7 @@ public int getSalePrice() { return salePrice; } - public List getBadges() { - return badges; + public Set getBadgeList() { + return badgeList; } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java new file mode 100644 index 000000000..33a4c3f31 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java @@ -0,0 +1,28 @@ +package com.codesquad.sidedish.SideDish.dto; + +import com.codesquad.sidedish.SideDish.domain.image.Image; + +public class ImageDto { + + private Long id; + private String imageUrl; + private String type; + + public ImageDto(Image image) { + this.id = image.getId(); + this.imageUrl = image.getImageUrl(); + this.type = image.getType(); + } + + public Long getId() { + return id; + } + + public String getImageUrl() { + return imageUrl; + } + + public String getType() { + return type; + } +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java new file mode 100644 index 000000000..1e25225e3 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java @@ -0,0 +1,35 @@ +package com.codesquad.sidedish.SideDish.dto; + +import com.codesquad.sidedish.SideDish.domain.sale.Sale; + +public class SaleDto { + + private Long id; + private String badge; + private String saleType; + private int saleValue; + + public SaleDto(Sale sale) { + this.id = sale.getId(); + this.badge = sale.getBadge(); + this.saleType = sale.getSaleType(); + this.saleValue = sale.getSaleValue(); + } + + public Long getId() { + return id; + } + + public String getBadge() { + return badge; + } + + public String getSaleType() { + return saleType; + } + + public int getSaleValue() { + return saleValue; + } + +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index f89a8815f..793c01d09 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -1,49 +1,67 @@ package com.codesquad.sidedish.SideDish.service; -import com.codesquad.sidedish.SideDish.domain.Dish; -import com.codesquad.sidedish.SideDish.domain.DishRepository; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; +import com.codesquad.sidedish.SideDish.domain.dish.DishRepository; +//import com.codesquad.sidedish.SideDish.dto.DishDetailDto; +//import com.codesquad.sidedish.SideDish.dto.DishDto; +//import com.codesquad.sidedish.SideDish.dto.QuantityDto; +//import com.codesquad.sidedish.SideDish.dto.RefreshDto; +import com.codesquad.sidedish.SideDish.domain.image.Image; +import com.codesquad.sidedish.SideDish.domain.image.ImageRepository; import com.codesquad.sidedish.SideDish.dto.DishDetailDto; import com.codesquad.sidedish.SideDish.dto.DishDto; -import com.codesquad.sidedish.SideDish.dto.QuantityDto; -import com.codesquad.sidedish.SideDish.dto.RefreshDto; -import com.codesquad.sidedish.SideDish.exception.DishNotFoundException; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; @Service public class DishService { private final DishRepository dishRepository; + private final ImageRepository imageRepository; - public DishService(DishRepository dishRepository) { + public DishService(DishRepository dishRepository, ImageRepository imageRepository) { this.dishRepository = dishRepository; + this.imageRepository = imageRepository; } - public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { - Dish dish = dishRepository.findByDetailHash(detailHash); - boolean refreshable = dish.refreshable(lastUpdated); - return new RefreshDto(refreshable); - } - public QuantityDto getDetailQuantity(String detailHash) { - return QuantityDto.from(getDish(detailHash)); - } +// public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { +// Dish dish = dishRepository.findByDetailHash(detailHash); +// boolean refreshable = dish.refreshable(lastUpdated); +// return new RefreshDto(refreshable); +// } +// +// public QuantityDto getDetailQuantity(String detailHash) { +// return QuantityDto.from(getDish(detailHash)); +// } +// +// public DishDetailDto getDetail(String detailHash) { +// Dish dish = dishRepository.findByDetailHash(detailHash); +// List tumb = imageRepository.findImagesByType("thum"); +// List detail = imageRepository.findImagesByType("detail"); +// DishDetailDto dishDetailDto = new DishDetailDto(dish, tumb, detail); +// return dishDetailDto; +// } +//// + public List getList(Long categoryId) { + List dishDtos = new ArrayList<>(); + for (Dish dish : dishRepository.findAll()) { + dishDtos.add(DishDto.from(dish)); + } + return dishDtos; - public DishDetailDto getDetail(String detailHash) { - return DishDetailDto.from(getDish(detailHash)); } - public List getList(long categoryId) { - return dishRepository.findAllByCategoryId(categoryId) - .stream().map(DishDto::from) - .collect(Collectors.toList()); - } +// private Dish getDish(String detailHash) { +// Dish dish = dishRepository.findByDetailHash(detailHash); +// return Optional.ofNullable(dish) +// .orElseThrow(() -> new DishNotFoundException(detailHash)); +// } + +// public List getList(Long categoryId) { +// return dishRepository.findAllByCategoryId(categoryId); +// } - private Dish getDish(String detailHash) { - Dish dish = dishRepository.findByDetailHash(detailHash); - return Optional.ofNullable(dish) - .orElseThrow(() -> new DishNotFoundException(detailHash)); - } } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index fe60961c2..9b92d4d24 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -6,4 +6,9 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.schema=classpath:schema.sql spring.datasource.initialization-mode=always +logging.level.com.codesquad. = DEBUG +logging.level.sql=DEBUG +logging.level.org.springframework.jdbc.core=DEBUG + + spring.jackson.serialization.INDENT_OUTPUT=true From 9d33a4ee19fea38e8b12556efd86aae3bd3f4970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Wed, 28 Apr 2021 20:07:18 +0900 Subject: [PATCH 08/18] =?UTF-8?q?[fix]=20=EB=B9=8C=EB=93=9C=EA=B0=80=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=ED=95=98=EB=8A=94=20=EB=B2=84=EA=B7=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/.gitignore | 4 ++++ .../java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/.gitignore b/backend/.gitignore index 64ce27d1f..6e5902f19 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -2,6 +2,10 @@ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +build +.gradle +.gradle/**/* + # User-specific stuff .idea/**/workspace.xml .idea/**/tasks.xml diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java index 64335b4f4..143885038 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java @@ -1,6 +1,6 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.dish.Dish; public class QuantityDto { private final int quantity; From 2371a001c0777d6da63d1b00f723e7c0f74d6e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 11:31:02 +0900 Subject: [PATCH 09/18] =?UTF-8?q?feat:=20h2=20=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=94=EC=96=B4=20properties=20=EC=99=80=20schema=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gradle/6.8.3/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes backend/build.gradle | 2 + .../src/main/resources/application.properties | 27 +- backend/src/main/resources/schema-h2.sql | 342 ++++++++++++++++++ 5 files changed, 362 insertions(+), 9 deletions(-) create mode 100644 backend/src/main/resources/schema-h2.sql diff --git a/backend/.gradle/6.8.3/fileHashes/fileHashes.lock b/backend/.gradle/6.8.3/fileHashes/fileHashes.lock index 0fdd98f4d8655a524485b76bbdef20a793b09c7e..91fa0e7419d99c996d0a85b19c73f9e61c1a7ed4 100644 GIT binary patch literal 17 UcmZQx;<;XitG1wm0Ss8&0Vsz9b^rhX literal 17 UcmZQx;<;XitG1wm0SuUn0VuHpp#T5? diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 82b7cce020c51fedcbd67438737acb7ff07d3c78..caee65c4eece4275b8558bb174ec0c830bb578d7 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~j!A001#e1Oxy8 literal 17 VcmZSX+g@Tc(fO$n0~j#A1pqP+1jqmY diff --git a/backend/build.gradle b/backend/build.gradle index ee7b74215..06d34179f 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -17,7 +17,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' + runtimeOnly 'mysql:mysql-connector-java' + runtimeOnly 'com.h2database:h2' // swagger implementation 'io.springfox:springfox-swagger2:2.9.2' diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 9b92d4d24..43da0379d 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,14 +1,23 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimeZone=Asia/Seoul -spring.datasource.username=bat -spring.datasource.password=bat1234 -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.datasource.schema=classpath:schema.sql -spring.datasource.initialization-mode=always - +# logging 관련 설정 logging.level.com.codesquad. = DEBUG logging.level.sql=DEBUG logging.level.org.springframework.jdbc.core=DEBUG - +# jackson 관련 설정 spring.jackson.serialization.INDENT_OUTPUT=true + +# h2 관련 설정 +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.initialization-mode=embedded +spring.datasource.url=jdbc:h2:~/test;SCHEMA=sidedish;MODE=MySQL;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.schema=classpath:schema-h2.sql +spring.datasource.username=sa +spring.datasource.password= + +## mysql 관련 설정 +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +#spring.datasource.initialization-mode=always +#spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimeZone=Asia/Seoul +#spring.datasource.schema=classpath:schema.sql +#spring.datasource.username=bat +#spring.datasource.password=bat1234 diff --git a/backend/src/main/resources/schema-h2.sql b/backend/src/main/resources/schema-h2.sql new file mode 100644 index 000000000..d008c652a --- /dev/null +++ b/backend/src/main/resources/schema-h2.sql @@ -0,0 +1,342 @@ +SET MODE MySQL; + +-- ----------------------------------------------------- +-- Schema mydb +-- ----------------------------------------------------- +-- ----------------------------------------------------- +-- Schema sidedish +-- ----------------------------------------------------- +DROP SCHEMA IF EXISTS `sidedish` ; + +-- ----------------------------------------------------- +-- Schema sidedish +-- ----------------------------------------------------- +CREATE SCHEMA IF NOT EXISTS `sidedish`; +USE `sidedish` ; + + +-- ----------------------------------------------------- +-- Table `sidedish`.`menu` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`category` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`category` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `category_name` VARCHAR(45) NOT NULL, + `end_point` VARCHAR(45) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `sidedish`.`dish` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish` ( + `detail_hash` VARCHAR(50), + `image` VARCHAR(100), + `title` VARCHAR(50), + `description` VARCHAR(100), + `price` INT(11), + `sale_price` INT(11), + `point` INT(11), + `delivery_info` VARCHAR(50), + `delivery_fee` INT(11), + `category_id` INT(11), + `quantity` INT(11), + `current_date_time` TIMESTAMP, + PRIMARY KEY (`detail_hash`)) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + +-- ----------------------------------------------------- +-- Table `sidedish`.`delivery` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`delivery` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`delivery` ( + `id` INT(11) NOT NULL, + `delivery_type` VARCHAR(45) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + +-- ----------------------------------------------------- +-- Table `sidedish`.`dish_delivery` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish_delivery` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_delivery`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `delivery` INT, + CONSTRAINT dish_delivery_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_delivery_delivery_foreign_key FOREIGN KEY (`delivery`) REFERENCES `delivery` (id) +); + + +-- ----------------------------------------------------- +-- Table `sidedish`.`sale` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`sale` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`sale` ( + `id` INT(11) NOT NULL, + `badge` VARCHAR(45) NOT NULL, + `sale_type` VARCHAR(45) NOT NULL, + `sale_value` INT(11) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `sidedish`.`dish_sale` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish_sale` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_sale`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `sale` INT, + CONSTRAINT dish_sale_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_sale_sale_foreign_key FOREIGN KEY (`sale`) REFERENCES `sale` (id) +); + + +DROP TABLE IF EXISTS `sidedish`.`image` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`image` ( + `id` INT(11) AUTO_INCREMENT NOT NULL, + `image_url` VARCHAR(100) NOT NULL, + `type` VARCHAR(45) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `sidedish`.`dish_sale` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `sidedish`.`dish_image` ; + +CREATE TABLE IF NOT EXISTS `sidedish`.`dish_image`( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `dish` VARCHAR (50), + `image` INT, + CONSTRAINT dish_image_dish_foreign_key FOREIGN KEY (`dish`) REFERENCES `dish` (detail_hash), + CONSTRAINT dish_image_image_foreign_key FOREIGN KEY (`image`) REFERENCES `image` (id) +); + + +INSERT INTO sidedish.category + (id, category_name, end_point) +VALUES + (1, '메인요리', '/main'), + (2, '국.찌개', '/soup'), + (3, '반찬', '/side'); + + +INSERT INTO sidedish.dish + (detail_hash, image, title, description, price, sale_price,point, delivery_info, delivery_fee, category_id, quantity) +VALUES + ('HBDEF', 'http://public.codesquad.kr/jk/storeapp/data/2d3f99a9a35601f4e98837bc4d39b2c8.jpg', '[미노리키친] 규동 250g', '일본인의 소울푸드! 한국인도 좋아하는 소고기덮밥', 6000, 5200, 52,'서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HDF73', 'http://public.codesquad.kr/jk/storeapp/data/7674311a02ba7c88675f3186ddaeef9e.jpg', '[빅마마의밥친구] 아삭 고소한 연근고기조림 250g', '편식하는 아이도 좋아하는 건강한 연근조림', 5500, null, 55, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HF778', 'http://public.codesquad.kr/jk/storeapp/data/cad8eee316cf7151e07638aa57b32a9d.jpg', '[소중한식사] 골뱅이무침 195g', '매콤새콤달콤, 반찬으로도 안주로도 좋은', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HFB53', 'http://public.codesquad.kr/jk/storeapp/data/b6beada6b89af950289003d929936d9c.jpg', '[옹가솜씨] 꽁치간장조림 240g', '[옹가솜씨] 꽁치간장조림 240g', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H077F', 'http://public.codesquad.kr/jk/storeapp/data/0221110ead70dfd455e40703bbdd6252.jpg', '[마더앤찬] 코다리구이 320g', '큼지막하고 살집 많은 동태 한 마리로 만든 코다리구이입니다.', 7500, 6750, 67, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H4665', 'http://public.codesquad.kr/jk/storeapp/data/385f4106ac26f6e4fe7c640714f405a5.jpg', '[남도애꽃] 반건조 문어조림 120g', '씹을수록 감칠맛나는 문어살의 쫄깃함', 4600, null, 46, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H1AA9', 'http://public.codesquad.kr/jk/storeapp/data/2455226945d52f5aefd51f35d663bb16.jpg', '[마샐미디쉬] 매콤마늘쫑 해산물볶음 180g', '탱글탱글한 새우와 오징어를 마늘쫑과 함께 매콤하게 볶아냈어요.', 6900, 6210, 62, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HEDFB', 'http://public.codesquad.kr/jk/storeapp/data/bc3b777115e8377a48c7bd762fe5fdc9.jpg', '[빅마마의밥친구] 비빔오징어 150g', '달콤한 신야초발효액이 포인트!', 5000, null, 50, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + + ('H72C3', 'http://public.codesquad.kr/jk/storeapp/data/d1fccf125f0a78113d0e06cb888f2e74.jpg', '[수하동] 특곰탕 850g', '100% 한우양지로 끓여낸 70년전통의 서울식곰탕', 15000, 14200, 142, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HA6EE', 'http://public.codesquad.kr/jk/storeapp/data/c069bc32cb37727c59e1f0c2839311a0.jpg', '[빅마마의밥친구] 된장찌개 900g', '항아리에서 숙성시킨 집된장으로만 맛을내 짜지 않은 된장찌개', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H8CD0', 'http://public.codesquad.kr/jk/storeapp/data/f31fc3f5828c27ff60e4cf89a862d31c.jpg', '[탐나는밥상] 동태탕 1000g', '칼칼한 국물이 속 풀기에 딱 좋은 동태탕', 14000, null, 140, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HE2E9', 'http://public.codesquad.kr/jk/storeapp/data/6edbb16da52708e8533b85fbf743f882.jpg', '[국물닷컴] 치즈부대찌개 600g', '안주용 부대찌개와는 달라 밥말아먹기 딱 좋은', 4300, null, 43, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HAA47', 'http://public.codesquad.kr/jk/storeapp/data/892f3e7f043bfa7dbbcd58f88eecac36.jpg', '[집밥의완성] 스키야키 1.5kg (2~3인분)', '진한 풍미의 일본식 전골, 스키야키', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H3254', 'http://public.codesquad.kr/jk/storeapp/data/ae571e13d18fd4f0f40d685d2c8fe8f1.jpg', '[새로미부산어묵] 프리미엄 어묵탕세트', '밀가루 0% 프리미엄 어묵에 어묵스프까지 드려요!', 18000, 14400, 144, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H26C7', 'http://public.codesquad.kr/jk/storeapp/data/8fd330b5f5dbccbcbf4f5731e5e9e29b.jpg', '[모이세] 육개장 1팩(600g)', '제주3대해장국 맛집의 인기메뉴', 5000, 4400, 44, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HFFF9', 'http://public.codesquad.kr/jk/storeapp/data/2416b58044d49f0d3a24256f8e76163b.jpg', '[마더앤찬] 명란감자국 630ml', '간간한 저염명란과 고소한 감자가 조화로운 국이에요', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + + ('HBBCC', 'http://public.codesquad.kr/jk/storeapp/data/fdb0d5fcfb86e332505785225a6d9ade.jpg', '[마샐미디쉬] 유자소스 연근무침 250g', '향긋한 유자향과 아삭한 연근', 6500, null, 65, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H1939', 'http://public.codesquad.kr/jk/storeapp/data/e5646e5fc09a01a9243979b229e0572b.jpg', '[동네부엌] 쇠고기야채장조림 200g', '부드러운 고기부터 밥비벼먹기 딱좋은 국물까지', 7400, null, 74, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H8EA5', 'http://public.codesquad.kr/jk/storeapp/data/4cfd1954861ebd18b5b53e558a8e902e.jpg', '[소중한식사] 도라지초무침 150g', '새콤달콤 입맛 돋우는', 4000, null, 40, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H602F', 'http://public.codesquad.kr/jk/storeapp/data/422befe07f7e2860b9a83a8d7049ec2e.jpg', '[미노리키친] 일본식 우엉조림(킨피라고보) 80g', '한국식 우엉조림과는 다른 진한 감칠맛', 3300, null, 33, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + + ('H9F0B', 'http://public.codesquad.kr/jk/storeapp/data/d0b5d2be962947d9534e2140d1b34b2d.jpg', '[빅마마의밥친구] 갈치포무침 150g', '쉽게 접할수 없는 꼬순내가득 갈치포 무침', 7000, null, 70, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H0FC6', 'http://public.codesquad.kr/jk/storeapp/data/f6817349118d4c671da8dca9065649a9.jpg', '[마더앤찬] 명란치즈계란말이 230g', '아이반찬으로 최고 계란말이', 3870, null, 38, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HCCFE', 'http://public.codesquad.kr/jk/storeapp/data/757878b14ee5a8d5af905c154fc38f01.jpg', '[옹가솜씨] 달걀곤약조림 330g', '칼로리 부담 쭉쭉 내린', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HB9C1', 'http://public.codesquad.kr/jk/storeapp/data/043cf496f07899e7515f761e29d1ffa9.jpg', '[너의반찬] 미소된장 고추무침 200g', '고소한 양념 때문에 손이 자꾸 가요', 4500, null, 45, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5); + +INSERT INTO sidedish.image + (id, image_url, type) +VALUES + (1, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4cce011a4a352c22cd399a60271b4921.jpg', 'thumb'), + (2, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/6ef14155afc5b47e8c9efd762f7a6096.jpg', 'thumb'), + (3, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/8744504ff3bc315f901dca1f26fe63a1.jpg', 'thumb'), + (4, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/e30bd6de9340fc05db3cd1d1329b2c56.jpg', 'thumb'), + (5, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/9c2c53b40a11b79c90549a058c2da4b7.jpg', 'detail'), + (6, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/70b0c77d3ef5cdd6269588685bbefe43.jpg', 'detail'), + (7, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/72f1049b047f65f42a267d5bbd1e6204.jpg', 'detail'), + (8, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/768afd17faa8bf3461b8160ba0aa26bf.jpg', 'detail'), + (9, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/95816f09d3294641f2e0feacaa739991.jpg', 'detail'), + (10, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/2450219a4686d9d6d579fc04020929b4.jpg', 'detail'), + (11, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4971475295545ec336c9479fabb25364.jpg', 'detail'), + (12, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/a8c434715709fe855f3ea1554ec362b6.jpg', 'detail'), + (13, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/b2b3d0d2107ab91b16e0eb804cd84bc9.jpg', 'detail'), + (14, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/c0dd6887c9d9368604fc70d7fc3c4598.jpg', 'detail'), + + (15, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0f95f44ea8e2e7930321def493753a48.jpg', 'thumb'), + (16, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/2d408898494ac950d7d2cfd6c36d59c2.jpg', 'thumb'), + (17, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/62c8bb77facfc9c3be81f9bf45b27f2a.jpg', 'thumb'), + (18, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/f6d73afc0ebc1efa71eaea32e9d846f2.jpg', 'thumb'), + (19, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (20, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/5f73c5c80b62ef63c8a8eecefe32fc29.jpg', 'detail'), + (21, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (22, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0253cdebc4972fefd6b94458024fe765.jpg', 'detail'), + (23, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/3299da0677b50c8c519adc0335271c49.jpg', 'detail'), + (24, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0642265b65dcc2490ab164ff428cbfe2.jpg', 'detail'), + (25, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/695683493c1ae475a175475f50d3259f.jpg', 'detail'), + (26, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/c8f9bed4f5c07585b869e3d171904a93.jpg', 'detail'), + (27, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d2e3274c95c832bc9bfbcebbd548f61b.jpg', 'detail'), + (28, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d9e4fa00652483d74b46317d38159a2f.jpg', 'detail'), + (29, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d7799b67683128642453f9e2b4c8ce84.jpg', 'detail'), + + + (30, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/4e96f386d5a5c4459bc0ac6ffd0c1fce.jpg', 'thumb'), + (31, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/00327d0df92e29bad02e7387349bed53.jpg', 'thumb'), + (32, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/781fea32c56eb102429902a2f62cbaf3.jpg', 'thumb'), + (33, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/edd7a54096d6df1b8bc8b318cea0191c.jpg', 'detail'), + (34, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/fb8e6e21faa8284021c1b1c7a1ae1281.jpg', 'detail'), + (35, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/36a0566d2fb69a4bcea946727181836d.jpg', 'detail'), + + (36, 'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/2ad963a9f63d371826748c852a0025c3.jpg', 'thumb'), + (37,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/f945d8ac1dccc3f931bcaf35de5de582.jpg', 'thumb'), + (38,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/bacb0b8186371bfafbd92dbeec718e13.jpg', 'thumb'), + (39,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b96b02e9a956c6d5ad1e10eb14ba81e0.jpg', 'thumb'), + (40,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/3d67aabd2751620367e1d1ac3e3d7ef2.jpg', 'detail'), + (41,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/855b42b4e80162e6930f06aa80bd1272.jpg', 'detail'), + (42,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/1966de56cf138639d5d50d4bf2db8e72.jpg', 'detail'), + (43,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b3dd54082745d1188f3a6e582e7cd993.jpg', 'detail'), + (44,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/4a6fd1fd1116c14aa6aef5e6851ab6a9.jpg', 'detail'), + (45,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/7e12275d669102d0269278a7c91ab49d.jpg', 'detail'), + (46,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/ab34ea3755f59a21662266eb62b7bc4b.jpg', 'detail'), + (47,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b0a70ff59a3b5360b6246b507693c4d4.jpg', 'detail'), + (48,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/dc772923b4a2e053f1baf68fa28a48ee.jpg', 'detail'), + + (49, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c8c8045696b4692107ef28c8b445ca42.jpg', 'thumb'), + (50, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/edc6bae2e2663f05b4e8eb5a2b95d68f.jpg', 'thumb'), + (51, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c935f5913dc66b11ebceeef85485c438.jpg', 'thumb'), + (52, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/7c1e24867611394f04b37d05593e21ba.jpg', 'thumb'), + (53, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/670e7deefe1d84a4f4e058655fbd4d7c.jpg', 'detail'), + (54, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/1898cda038e92454395b8ffca8cd4393.jpg', 'detail'), + (55, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49516d302dad870fbdd75cf98a01eae4.jpg', 'detail'), + (56, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c1bb6fe4f72fcea27ea989ae48c61c86.jpg', 'detail'), + (57, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49afed8d3ec417b39ce8de456fc6661c.jpg', 'detail'), + (58, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/e62762e63f3e12dc2857a065badf1eea.jpg', 'detail'), + (59, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/31103ab946bff52b709ec6891e768c05.jpg', 'detail'), + (60, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/f84dc16f4f6d97661bd13d587a72d6b1.jpg', 'detail'), + (61, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/fd3f49614f731a0610a5409c0deb3c60.jpg', 'detail'), + + (62, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/43c38eeffa556554c9b06301eb3e85b2.jpg', 'thumb'), + (63, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/92f556b605c4a84813070d7214c4f336.jpg', 'thumb'), + (64, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/538b8ab021c7814aa4af860d94f81287.jpg', 'thumb'), + (65, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/adaef08ab0680b087096afa0f0070fad.jpg', 'thumb'), + (66, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/341b8605fa224ec1808c4f169097d170.jpg', 'detail'), + (67, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/0228d4cb660a3cca06952917bd024dcb.jpg', 'detail'), + (68, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e027227f61a93b6473e8c4bbd5c3de74.jpg', 'detail'), + (69, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/03ac0b09199421bb61727c667c2361f6.jpg', 'detail'), + (70, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/cbe4a3e12b7bdba5cf410e0e19dcf1ca.jpg', 'detail'), + (71,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/b58fa5791b67db106524b48442cb1c6a.jpg', 'detail'), + (72,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/82cfe0332f0e1c927a23b79f1d152430.jpg', 'detail'), + (73,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/390ca9ad5a574cbe7f3f6e26871f6690.jpg', 'detail'), + (74,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e113889a6120357c8e6196802a9f155b.jpg', 'detail'), + (75,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/967e8e1ef357e9722b796e2bcb09ba3d.jpg', 'detail'); + +INSERT INTO sidedish.dish_image + (dish, image) +values + ('HBDEF', 1),('HBDEF', 2),('HBDEF', 3),('HBDEF', 4),('HBDEF', 5),('HBDEF', 6),('HBDEF', 7),('HBDEF', 8),('HBDEF', 9),('HBDEF', 10),('HBDEF', 11),('HBDEF', 12),('HBDEF', 13),('HBDEF', 14), + ('HDF73', 15),('HDF73', 16),('HDF73', 17),('HDF73', 18),('HDF73', 19),('HDF73', 20),('HDF73', 21),('HDF73', 22),('HDF73', 23),('HDF73', 24),('HDF73', 25),('HDF73', 26),('HDF73', 27),('HDF73', 28),('HDF73', 29), + ('HF778', 1),('HF778', 2),('HF778', 3),('HF778', 4),('HF778', 5),('HF778', 6),('HF778', 7),('HF778', 8),('HF778', 9),('HF778', 10),('HF778', 11),('HF778', 12),('HF778', 13),('HF778', 14), + ('HFB53', 1),('HFB53', 2),('HFB53', 3),('HFB53', 4),('HFB53', 5),('HFB53', 6),('HFB53', 7),('HFB53', 8),('HFB53', 9),('HFB53', 10),('HFB53', 11),('HFB53', 12),('HFB53', 13),('HFB53', 14), + ('H077F', 1),('H077F', 2),('H077F', 3),('H077F', 4),('H077F', 5),('H077F', 6),('H077F', 7),('H077F', 8),('H077F', 9),('H077F', 10),('H077F', 11),('H077F', 12),('H077F', 13),('H077F', 14), + ('H4665', 15),('H4665', 16),('H4665', 17),('H4665', 18),('H4665', 19),('H4665', 20),('H4665', 21),('H4665', 22),('H4665', 23),('H4665', 24),('H4665', 25),('H4665', 26),('H4665', 27),('H4665', 28),('H4665', 29), + ('H1AA9', 15),('H1AA9', 16),('H1AA9', 17),('H1AA9', 18),('H1AA9', 19),('H1AA9', 20),('H1AA9', 21),('H1AA9', 22),('H1AA9', 23),('H1AA9', 24),('H1AA9', 25),('H1AA9', 26),('H1AA9', 27),('H1AA9', 28),('H1AA9', 29), + ('HEDFB', 15),('HEDFB', 16),('HEDFB', 17),('HEDFB', 18),('HEDFB', 19),('HEDFB', 20),('HEDFB', 21),('HEDFB', 22),('HEDFB', 23),('HEDFB', 24),('HEDFB', 25),('HEDFB', 26),('HEDFB', 27),('HEDFB', 28),('HEDFB', 29), + + ('H72C3', 30),('H72C3', 31),('H72C3', 32),('H72C3', 33),('H72C3', 34),('H72C3', 35), + ('HA6EE', 30),('HA6EE', 31),('HA6EE', 32),('HA6EE', 33),('HA6EE', 34),('HA6EE', 35), + ('H8CD0', 30),('H8CD0', 31),('H8CD0', 32),('H8CD0', 33),('H8CD0', 34),('H8CD0', 35), + ('HE2E9', 30),('HE2E9', 31),('HE2E9', 32),('HE2E9', 33),('HE2E9', 34),('HE2E9', 35), + ('HAA47', 30),('HAA47', 31),('HAA47', 32),('HAA47', 33),('HAA47', 34),('HAA47', 35), + ('H3254', 36),('H3254', 37),('H3254', 38),('H3254', 39),('H3254', 40),('H3254', 41),('H3254', 42),('H3254', 43),('H3254', 44),('H3254', 45),('H3254', 46),('H3254', 47),('H3254', 48), + ('H26C7', 36),('H26C7', 37),('H26C7', 38),('H26C7', 39),('H26C7', 40),('H26C7', 41),('H26C7', 42),('H26C7', 43),('H26C7', 44),('H26C7', 45),('H26C7', 46),('H26C7', 47),('H26C7', 48), + ('HFFF9', 36),('HFFF9', 37),('HFFF9', 38),('HFFF9', 39),('HFFF9', 40),('HFFF9', 41),('HFFF9', 42),('HFFF9', 43),('HFFF9', 44),('HFFF9', 45),('HFFF9', 46),('HFFF9', 47),('HFFF9', 48), + + ('HBBCC', 49),('HBBCC', 50),('HBBCC', 51),('HBBCC', 52),('HBBCC', 53),('HBBCC', 54),('HBBCC', 55),('HBBCC', 56),('HBBCC', 57),('HBBCC', 58),('HBBCC', 59),('HBBCC', 60),('HBBCC', 61), + ('H1939', 49),('H1939', 50),('H1939', 51),('H1939', 52),('H1939', 53),('H1939', 54),('H1939', 55),('H1939', 56),('H1939', 57),('H1939', 58),('H1939', 59),('H1939', 60),('H1939', 61), + ('H8EA5', 49),('H8EA5', 50),('H8EA5', 51),('H8EA5', 52),('H8EA5', 53),('H8EA5', 54),('H8EA5', 55),('H8EA5', 56),('H8EA5', 57),('H8EA5', 58),('H8EA5', 59),('H8EA5', 60),('H8EA5', 61), + ('H602F', 49),('H602F', 50),('H602F', 51),('H602F', 52),('H602F', 53),('H602F', 54),('H602F', 55),('H602F', 56),('H602F', 57),('H602F', 58),('H602F', 59),('H602F', 60),('H602F', 61), + ('H9F0B', 62),('H9F0B', 63),('H9F0B', 64),('H9F0B', 65),('H9F0B', 66),('H9F0B', 67),('H9F0B', 68),('H9F0B', 69),('H9F0B', 70),('H9F0B', 71),('H9F0B', 72),('H9F0B', 73),('H9F0B', 74),('H9F0B', 75), + ('H0FC6', 62),('H0FC6', 63),('H0FC6', 64),('H0FC6', 65),('H0FC6', 66),('H0FC6', 67),('H0FC6', 68),('H0FC6', 69),('H0FC6', 70),('H0FC6', 71),('H0FC6', 72),('H0FC6', 73),('H0FC6', 74),('H0FC6', 75), + ('HCCFE', 62),('HCCFE', 63),('HCCFE', 64),('HCCFE', 65),('HCCFE', 66),('HCCFE', 67),('HCCFE', 68),('HCCFE', 69),('HCCFE', 70),('HCCFE', 71),('HCCFE', 72),('HCCFE', 73),('HCCFE', 74),('HCCFE', 75), + ('HB9C1', 62),('HB9C1', 63),('HB9C1', 64),('HB9C1', 65),('HB9C1', 66),('HB9C1', 67),('HB9C1', 68),('HB9C1', 69),('HB9C1', 70),('HB9C1', 71),('HB9C1', 72),('HB9C1', 73),('HB9C1', 74),('HB9C1', 75); + +INSERT INTO sidedish.sale + (id, badge, sale_type, sale_value) +VALUES + (1, '이벤트특가', 'percentage', 10), + (2, '런칭특가', 'minus', 1000); + +INSERT INTO sidedish.dish_sale + (dish, sale) +VALUES + ('HBDEF', 1), + ('HF778', 1), + ('H077F', 1), + ('H1AA9', 1), + ('H72C3', 1), + ('H72C3', 2), + ('H3254', 1), + ('H3254', 2), + ('H26C7', 1), + ('H26C7', 2), + ('HFFF9', 1), + ('HFFF9', 2); + +INSERT INTO sidedish.delivery + (id, delivery_type) +VALUES + (1, '새벽배송'), + (2, '전국택배'); + +INSERT INTO sidedish.dish_delivery + (dish, delivery) +VALUES + ('HBDEF', 1), ('HBDEF', 2), + ('HDF73', 1), ('HDF73', 2), + ('HF778', 1), ('HF778', 2), + ('HFB53', 1),('HFB53', 2), + ('H077F', 1),('H077F', 2), + ('H4665', 1),('H4665', 2), + ('H1AA9', 1),('H1AA9', 2), + ('HEDFB', 1),('HEDFB', 2), + ('H72C3', 1),('H72C3', 2), + ('HA6EE', 1),('HA6EE', 2), + ('H8CD0', 1),('H8CD0', 2), + ('HE2E9', 1),('HE2E9', 2), + ('HAA47', 1),('HAA47', 2), + ('H3254', 1),('H3254', 2), + ('H26C7', 1),('H26C7', 2), + ('HFFF9', 1),('HFFF9', 2), + ('HBBCC', 1),('HBBCC', 2), + ('H1939', 1),('H1939', 2), + ('H8EA5', 1),('H8EA5', 2), + ('H602F', 1),('H602F', 2), + ('H9F0B', 1),('H9F0B', 2), + ('H0FC6', 1),('H0FC6', 2), + ('HCCFE', 1),('HCCFE', 2), + ('HB9C1', 1),('HB9C1', 2); From 2d4c4c0df151ca3ad91fd5810effef613146a1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 15:14:50 +0900 Subject: [PATCH 10/18] =?UTF-8?q?feat:=20Spring=20profile=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95;=20prod=20&=20dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../buildOutputCleanup/cache.properties | 4 +- backend/README.md | 10 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- backend/gradlew | 0 backend/gradlew.bat | 178 +++++++++--------- .../SideDish/controller/DishController.java | 56 ++---- .../domain/{delivery => }/Delivery.java | 2 +- .../SideDish/domain/{dish => }/Dish.java | 14 +- .../domain/{delivery => }/DishDelivery.java | 4 +- .../domain/{image => }/DishImage.java | 3 +- .../domain/{dish => }/DishRepository.java | 7 +- .../SideDish/domain/{sale => }/DishSale.java | 3 +- .../SideDish/domain/{image => }/Image.java | 2 +- .../SideDish/domain/{sale => }/Sale.java | 2 +- .../domain/delivery/DeliveryRepository.java | 7 - .../domain/image/ImageRepository.java | 9 - .../SideDish/domain/sale/SaleRepository.java | 7 - .../sidedish/SideDish/dto/DeliveryDto.java | 24 --- .../sidedish/SideDish/dto/DishDetailDto.java | 65 ++++++- .../sidedish/SideDish/dto/DishDto.java | 76 ++++---- .../sidedish/SideDish/dto/ImageDto.java | 28 --- .../sidedish/SideDish/dto/QuantityDto.java | 3 +- .../sidedish/SideDish/dto/SaleDto.java | 35 ---- .../SideDish/service/DishService.java | 34 ++-- .../main/resources/application-dev.properties | 9 + .../resources/application-prod.properties | 9 + .../src/main/resources/application.properties | 23 --- backend/src/main/resources/common.properties | 7 + .../main/resources/{ => dev}/schema-h2.sql | 1 + .../src/main/resources/{ => prod}/data.sql | 0 .../src/main/resources/{ => prod}/schema.sql | 0 .../SideDish/SideDishApplicationTests.java | 94 --------- .../domain/CategoryRepositoryTest.java | 47 +++++ 34 files changed, 309 insertions(+), 456 deletions(-) mode change 100644 => 100755 backend/gradlew rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{delivery => }/Delivery.java (91%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{dish => }/Dish.java (84%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{delivery => }/DishDelivery.java (82%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{image => }/DishImage.java (81%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{dish => }/DishRepository.java (69%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{sale => }/DishSale.java (81%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{image => }/Image.java (92%) rename backend/src/main/java/com/codesquad/sidedish/SideDish/domain/{sale => }/Sale.java (93%) delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java create mode 100644 backend/src/main/resources/application-dev.properties create mode 100644 backend/src/main/resources/application-prod.properties delete mode 100644 backend/src/main/resources/application.properties create mode 100644 backend/src/main/resources/common.properties rename backend/src/main/resources/{ => dev}/schema-h2.sql (99%) rename backend/src/main/resources/{ => prod}/data.sql (100%) rename backend/src/main/resources/{ => prod}/schema.sql (100%) delete mode 100644 backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java create mode 100644 backend/src/test/java/com/codesquad/sidedish/SideDish/domain/CategoryRepositoryTest.java diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index caee65c4eece4275b8558bb174ec0c830bb578d7..1c675bd093320cfd4eadeb0e535330f0727531b7 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~jzJ1pqPW1fc)` literal 17 VcmZSX+g@Tc(fO$n0~j!A001#e1Oxy8 diff --git a/backend/.gradle/buildOutputCleanup/cache.properties b/backend/.gradle/buildOutputCleanup/cache.properties index ba7cfe071..54578b563 100644 --- a/backend/.gradle/buildOutputCleanup/cache.properties +++ b/backend/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Tue Apr 20 01:45:16 KST 2021 -gradle.version=6.8.3 +#Thu Apr 29 14:48:25 KST 2021 +gradle.version=7.0 diff --git a/backend/README.md b/backend/README.md index a70de8974..e214342c6 100644 --- a/backend/README.md +++ b/backend/README.md @@ -5,3 +5,13 @@ ## API 배포 링크 http://3.37.26.82:8080/swagger-ui.html + +## 로컬 IntelliJ 로 실행하는 법 + +Edit Configurations 에서 Active profile 을 "dev" 혹은 "prod" 로 설정하자 + +## 빌드한 jar 를 실행하는 법 + +```sh +java -jar SideDish-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev +``` diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties index 442d9132e..f371643ee 100644 --- a/backend/gradle/wrapper/gradle-wrapper.properties +++ b/backend/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/backend/gradlew b/backend/gradlew old mode 100644 new mode 100755 diff --git a/backend/gradlew.bat b/backend/gradlew.bat index 107acd32c..ac1b06f93 100644 --- a/backend/gradlew.bat +++ b/backend/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java index be88cb1b0..4c5068e24 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java @@ -1,15 +1,13 @@ package com.codesquad.sidedish.SideDish.controller; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; -import com.codesquad.sidedish.SideDish.dto.*; +import com.codesquad.sidedish.SideDish.dto.CategoryDto; +import com.codesquad.sidedish.SideDish.dto.DishDto; import com.codesquad.sidedish.SideDish.service.CategoryService; import com.codesquad.sidedish.SideDish.service.DishService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -32,7 +30,7 @@ public ResponseEntity> getCategories() { return ResponseEntity.ok().body(categories); } -// @GetMapping("/detail/{detailHash}") + // @GetMapping("/detail/{detailHash}") // @ApiOperation(value = "요리 상세", notes = "요리의 상세 정보를 반환합니다.") // public ResponseEntity getDetail(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { // DishDetailDto dishDetailDto = dishService.getDetail(detailHash); @@ -59,42 +57,18 @@ public ResponseEntity> getMainList() { List dishes = dishService.getList(1L); return ResponseEntity.ok().body(dishes); } -// -// @GetMapping("/side") -// @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") -// public ResponseEntity> getSideList() { -// List dishes = dishService.getList(3); -// return ResponseEntity.ok().body(dishes); -// } -// -// @GetMapping("/soup") -// @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") -// public ResponseEntity> getSoupList() { -// List dishes = dishService.getList(2); -// return ResponseEntity.ok().body(dishes); -// } - -// @GetMapping("/main") -// @ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") -// public ResponseEntity> getMainList() { -// List dishes = dishService.getList(1L); -// return ResponseEntity.ok().body(dishes); -// } -// -// @GetMapping("/side") -// @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") -// public ResponseEntity> getSideList() { -// List dishes = dishService.getList(3L); -// return ResponseEntity.ok().body(dishes); -// } -// -// @GetMapping("/soup") -// @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") -// public ResponseEntity> getSoupList() { -// List dishes = dishService.getList(2L); -// return ResponseEntity.ok().body(dishes); -// } -// + @GetMapping("/soup") + @ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") + public ResponseEntity> getSoupList() { + List dishes = dishService.getList(2L); + return ResponseEntity.ok().body(dishes); + } + @GetMapping("/side") + @ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") + public ResponseEntity> getSideList() { + List dishes = dishService.getList(3L); + return ResponseEntity.ok().body(dishes); + } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java similarity index 91% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java index 72e7108e9..023a79ba2 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/Delivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java @@ -1,4 +1,4 @@ -package com.codesquad.sidedish.SideDish.domain.delivery; +package com.codesquad.sidedish.SideDish.domain; import org.springframework.data.annotation.Id; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java similarity index 84% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index 711ca7972..3137b5af1 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -1,11 +1,6 @@ -package com.codesquad.sidedish.SideDish.domain.dish; +package com.codesquad.sidedish.SideDish.domain; -import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; -import com.codesquad.sidedish.SideDish.domain.image.DishImage; -import com.codesquad.sidedish.SideDish.domain.sale.DishSale; -import com.codesquad.sidedish.SideDish.dto.SaleDto; import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.relational.core.mapping.Table; import java.time.LocalDateTime; @@ -49,8 +44,8 @@ public Dish(String detailHash, String image, String title, String description, i this.currentDateTime = LocalDateTime.now(); } - public void addImage(DishImage... dishImages){ - for(DishImage dishImage: dishImages) { + public void addImage(DishImage... dishImages) { + for (DishImage dishImage : dishImages) { this.dishImages.add(dishImage); } } @@ -130,9 +125,6 @@ public String toString() { ", categoryId=" + categoryId + ", quantity=" + quantity + ", currentDateTime=" + currentDateTime + -// ", dishSales=" + dishSales + -// ", dishDeliveries=" + dishDeliveries + -// ", dishImages=" + dishImages + '}'; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java similarity index 82% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java index 1e6b7df82..a26e828b5 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DishDelivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java @@ -1,6 +1,5 @@ -package com.codesquad.sidedish.SideDish.domain.delivery; +package com.codesquad.sidedish.SideDish.domain; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.PersistenceConstructor; @@ -29,5 +28,4 @@ public String getDish() { public Long getDelivery() { return delivery; } - } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java similarity index 81% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java index eeda0b750..712e97c0d 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/DishImage.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java @@ -1,6 +1,5 @@ -package com.codesquad.sidedish.SideDish.domain.image; +package com.codesquad.sidedish.SideDish.domain; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.PersistenceConstructor; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java similarity index 69% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java index 0baadda4d..8554b96d9 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/dish/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java @@ -1,16 +1,11 @@ -package com.codesquad.sidedish.SideDish.domain.dish; +package com.codesquad.sidedish.SideDish.domain; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; import java.util.List; public interface DishRepository extends CrudRepository { -// @Query("SELECT detail_hash FROM dish WHERE DISH.CATEGORY_ID =:categoryId" - - - List findAllByCategoryId(Long categoryId); Dish findByDetailHash(String detailHash); diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java similarity index 81% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java index a6ada21fd..5bac80c75 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/DishSale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java @@ -1,6 +1,5 @@ -package com.codesquad.sidedish.SideDish.domain.sale; +package com.codesquad.sidedish.SideDish.domain; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.PersistenceConstructor; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java similarity index 92% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java index a13dcaeec..2cc1e0718 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/Image.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java @@ -1,4 +1,4 @@ -package com.codesquad.sidedish.SideDish.domain.image; +package com.codesquad.sidedish.SideDish.domain; import org.springframework.data.annotation.Id; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java similarity index 93% rename from backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java rename to backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java index 783ed05f0..e12708041 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/Sale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java @@ -1,4 +1,4 @@ -package com.codesquad.sidedish.SideDish.domain.sale; +package com.codesquad.sidedish.SideDish.domain; import org.springframework.data.annotation.Id; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java deleted file mode 100644 index d89cf71e0..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/delivery/DeliveryRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain.delivery; - -import org.springframework.data.repository.CrudRepository; - -public interface DeliveryRepository extends CrudRepository { - -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java deleted file mode 100644 index 962f7b03c..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/image/ImageRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain.image; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface ImageRepository extends CrudRepository { - List findImagesByType(String type); -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java deleted file mode 100644 index fe43e6fa6..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/sale/SaleRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain.sale; - -import org.springframework.data.repository.CrudRepository; - -public interface SaleRepository extends CrudRepository { - -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java deleted file mode 100644 index ccc97bd96..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DeliveryDto.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.codesquad.sidedish.SideDish.dto; - -import com.codesquad.sidedish.SideDish.domain.delivery.Delivery; - -public class DeliveryDto { - - private Long id; - private String deliveryType; - - public DeliveryDto(Delivery delivery) { - this.id = delivery.getId(); - this.deliveryType = delivery.getDeliveryType(); - } - - public Long getId() { - return id; - } - - public String getDeliveryType() { - return deliveryType; - } - - -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java index e528c3326..90485932e 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java @@ -1,10 +1,9 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; -import com.codesquad.sidedish.SideDish.domain.image.Image; +import com.codesquad.sidedish.SideDish.domain.Dish; +import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; public class DishDetailDto { private final List thumbImages; @@ -13,12 +12,60 @@ public class DishDetailDto { private int deliveryFee; private final List detailImages; - public DishDetailDto(Dish dish, List thumbImages, List detailImages) { - this.thumbImages = thumbImages.stream().map(Image::getImageUrl).collect(Collectors.toList()); - this.point = dish.getPoint(); - this.deliveryInfo = dish.getDeliveryInfo(); - this.deliveryFee = dish.getDeliveryFee(); - this.detailImages = detailImages.stream().map(Image::getImageUrl).collect(Collectors.toList()); + private DishDetailDto(Builder builder) { + this.thumbImages = builder.thumbImages; + this.point = builder.point; + this.deliveryInfo = builder.deliveryInfo; + this.deliveryFee = builder.deliveryFee; + this.detailImages = builder.detailImages; + } + + public static DishDetailDto from(Dish dish) { + return new Builder() + .thumbImages(Arrays.asList("", "")) // TODO: + .point(dish.getPoint()) + .deliveryInfo(dish.getDeliveryInfo()) + .deliveryFee(dish.getDeliveryFee()) + .detailImages(Arrays.asList("", "")) // TODO: + .build(); + } + + private static class Builder { + private List thumbImages; + private int point; + private String deliveryInfo; + private int deliveryFee; + private List detailImages; + + public DishDetailDto build() { + return new DishDetailDto(this); + } + + + public Builder thumbImages(List thumbImages) { + this.thumbImages = thumbImages; + return this; + } + + public Builder point(int point) { + this.point = point; + return this; + } + + public Builder deliveryInfo(String deliveryInfo) { + this.deliveryInfo = deliveryInfo; + return this; + } + + public Builder deliveryFee(int deliveryFee) { + this.deliveryFee = deliveryFee; + return this; + } + + public Builder detailImages(List detailSection) { + this.detailImages = detailSection; + return this; + } } public List getThumbImages() { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java index cf7bea0f6..837ebe3c7 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java @@ -1,27 +1,31 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; -import com.codesquad.sidedish.SideDish.domain.sale.DishSale; -import com.codesquad.sidedish.SideDish.domain.sale.Sale; -import javafx.util.Builder; -import java.util.HashSet; +import com.codesquad.sidedish.SideDish.domain.Dish; + +import java.util.Arrays; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; public class DishDto { private final String detailHash; private final String image; private final String title; private final String description; + private final List deliveryTypes; private final int price; private final int salePrice; + private final List badges; - - private Set badgeList; - + private DishDto(Builder builder) { + this.detailHash = builder.detailHash; + this.image = builder.image; + this.deliveryTypes = builder.deliveryTypes; + this.title = builder.title; + this.description = builder.description; + this.price = builder.price; + this.salePrice = builder.salePrice; + this.badges = builder.badges; + } public static DishDto from(Dish dish) { return new Builder() @@ -29,38 +33,28 @@ public static DishDto from(Dish dish) { .image(dish.getImage()) .title(dish.getTitle()) .description(dish.getDescription()) + .deliveryTypes(Arrays.asList("", "")) // TODO: .price(dish.getPrice()) .salePrice(dish.getSalePrice()) - .badgeList(dish.getDishSales().stream() - .map(dishSale -> new SaleDto(new Sale("badge", "saleType", 0))) // TODO: 가라 데이터를 정상 - .collect(Collectors.toSet())) + .badges(Arrays.asList("", "")) // TODO: .build(); } - public DishDto(Builder builder) { - this.detailHash = builder.detailHash; - this.image = builder.image; - this.title = builder.title; - this.description = builder.description; - this.price = builder.price; - this.salePrice = builder.salePrice; - this.badgeList = builder.badgeList; - } - public static class Builder { - private String detailHash; - private String image; - private String title; - private String description; - private int price; - private int salePrice; - - private Set badgeList; + private String detailHash; + private String image; + private String title; + private String description; + private List deliveryTypes; + private int price; + private int salePrice; + private List badges; public DishDto build() { return new DishDto(this); } + public Builder detailHash(String detailHash) { this.detailHash = detailHash; return this; @@ -81,6 +75,11 @@ public Builder description(String description) { return this; } + public Builder deliveryTypes(List deliveryTypes) { + this.deliveryTypes = deliveryTypes; + return this; + } + public Builder price(int price) { this.price = price; return this; @@ -91,11 +90,10 @@ public Builder salePrice(int salePrice) { return this; } - public Builder badgeList(Set badgeList) { - this.badgeList = badgeList; + public Builder badges(List badges) { + this.badges = badges; return this; } - } public String getDetailHash() { @@ -106,6 +104,10 @@ public String getImage() { return image; } + public List getDeliveryTypes() { + return deliveryTypes; + } + public String getTitle() { return title; } @@ -122,7 +124,7 @@ public int getSalePrice() { return salePrice; } - public Set getBadgeList() { - return badgeList; + public List getBadges() { + return badges; } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java deleted file mode 100644 index 33a4c3f31..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/ImageDto.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.codesquad.sidedish.SideDish.dto; - -import com.codesquad.sidedish.SideDish.domain.image.Image; - -public class ImageDto { - - private Long id; - private String imageUrl; - private String type; - - public ImageDto(Image image) { - this.id = image.getId(); - this.imageUrl = image.getImageUrl(); - this.type = image.getType(); - } - - public Long getId() { - return id; - } - - public String getImageUrl() { - return imageUrl; - } - - public String getType() { - return type; - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java index 143885038..915e50a05 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java @@ -1,6 +1,7 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; + +import com.codesquad.sidedish.SideDish.domain.Dish; public class QuantityDto { private final int quantity; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java deleted file mode 100644 index 1e25225e3..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/SaleDto.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.codesquad.sidedish.SideDish.dto; - -import com.codesquad.sidedish.SideDish.domain.sale.Sale; - -public class SaleDto { - - private Long id; - private String badge; - private String saleType; - private int saleValue; - - public SaleDto(Sale sale) { - this.id = sale.getId(); - this.badge = sale.getBadge(); - this.saleType = sale.getSaleType(); - this.saleValue = sale.getSaleValue(); - } - - public Long getId() { - return id; - } - - public String getBadge() { - return badge; - } - - public String getSaleType() { - return saleType; - } - - public int getSaleValue() { - return saleValue; - } - -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 793c01d09..6d99075dc 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -1,33 +1,31 @@ package com.codesquad.sidedish.SideDish.service; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; -import com.codesquad.sidedish.SideDish.domain.dish.DishRepository; -//import com.codesquad.sidedish.SideDish.dto.DishDetailDto; -//import com.codesquad.sidedish.SideDish.dto.DishDto; -//import com.codesquad.sidedish.SideDish.dto.QuantityDto; -//import com.codesquad.sidedish.SideDish.dto.RefreshDto; -import com.codesquad.sidedish.SideDish.domain.image.Image; -import com.codesquad.sidedish.SideDish.domain.image.ImageRepository; -import com.codesquad.sidedish.SideDish.dto.DishDetailDto; +import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.DishRepository; import com.codesquad.sidedish.SideDish.dto.DishDto; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Service public class DishService { private final DishRepository dishRepository; - private final ImageRepository imageRepository; - public DishService(DishRepository dishRepository, ImageRepository imageRepository) { + public DishService(DishRepository dishRepository) { this.dishRepository = dishRepository; - this.imageRepository = imageRepository; + } + + public List getList(Long categoryId) { + List dishDtos = new ArrayList<>(); + for (Dish dish : dishRepository.findAll()) { + dishDtos.add(DishDto.from(dish)); + } + return dishDtos; } -// public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { + // public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { // Dish dish = dishRepository.findByDetailHash(detailHash); // boolean refreshable = dish.refreshable(lastUpdated); // return new RefreshDto(refreshable); @@ -45,14 +43,6 @@ public DishService(DishRepository dishRepository, ImageRepository imageRepositor // return dishDetailDto; // } //// - public List getList(Long categoryId) { - List dishDtos = new ArrayList<>(); - for (Dish dish : dishRepository.findAll()) { - dishDtos.add(DishDto.from(dish)); - } - return dishDtos; - - } // private Dish getDish(String detailHash) { // Dish dish = dishRepository.findByDetailHash(detailHash); diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties new file mode 100644 index 000000000..999edc71d --- /dev/null +++ b/backend/src/main/resources/application-dev.properties @@ -0,0 +1,9 @@ +spring.config.import=classpath:common.properties + +# h2 관련 설정 +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.initialization-mode=always +spring.datasource.url=jdbc:h2:~/test;MODE=MySQL;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.schema=classpath:dev/schema-h2.sql +spring.datasource.username=sa +spring.datasource.password= diff --git a/backend/src/main/resources/application-prod.properties b/backend/src/main/resources/application-prod.properties new file mode 100644 index 000000000..f76f65c08 --- /dev/null +++ b/backend/src/main/resources/application-prod.properties @@ -0,0 +1,9 @@ +spring.config.import=classpath:common.properties + +# mysql 관련 설정 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.initialization-mode=always +spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimeZone=Asia/Seoul +spring.datasource.schema=classpath:prod/schema.sql +spring.datasource.username=bat +spring.datasource.password=bat1234 diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties deleted file mode 100644 index 43da0379d..000000000 --- a/backend/src/main/resources/application.properties +++ /dev/null @@ -1,23 +0,0 @@ -# logging 관련 설정 -logging.level.com.codesquad. = DEBUG -logging.level.sql=DEBUG -logging.level.org.springframework.jdbc.core=DEBUG - -# jackson 관련 설정 -spring.jackson.serialization.INDENT_OUTPUT=true - -# h2 관련 설정 -spring.datasource.driver-class-name=org.h2.Driver -spring.datasource.initialization-mode=embedded -spring.datasource.url=jdbc:h2:~/test;SCHEMA=sidedish;MODE=MySQL;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE -spring.datasource.schema=classpath:schema-h2.sql -spring.datasource.username=sa -spring.datasource.password= - -## mysql 관련 설정 -#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -#spring.datasource.initialization-mode=always -#spring.datasource.url=jdbc:mysql://localhost:3306/sidedish?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimeZone=Asia/Seoul -#spring.datasource.schema=classpath:schema.sql -#spring.datasource.username=bat -#spring.datasource.password=bat1234 diff --git a/backend/src/main/resources/common.properties b/backend/src/main/resources/common.properties new file mode 100644 index 000000000..bf2e12e8b --- /dev/null +++ b/backend/src/main/resources/common.properties @@ -0,0 +1,7 @@ +# logging 관련 설정 +logging.level.com.codesquad. = DEBUG +logging.level.sql=DEBUG +logging.level.org.springframework.jdbc.core=DEBUG + +# jackson 관련 설정 +spring.jackson.serialization.INDENT_OUTPUT=true diff --git a/backend/src/main/resources/schema-h2.sql b/backend/src/main/resources/dev/schema-h2.sql similarity index 99% rename from backend/src/main/resources/schema-h2.sql rename to backend/src/main/resources/dev/schema-h2.sql index d008c652a..a8b344a25 100644 --- a/backend/src/main/resources/schema-h2.sql +++ b/backend/src/main/resources/dev/schema-h2.sql @@ -1,4 +1,5 @@ SET MODE MySQL; +DROP ALL OBJECTS; -- ----------------------------------------------------- -- Schema mydb diff --git a/backend/src/main/resources/data.sql b/backend/src/main/resources/prod/data.sql similarity index 100% rename from backend/src/main/resources/data.sql rename to backend/src/main/resources/prod/data.sql diff --git a/backend/src/main/resources/schema.sql b/backend/src/main/resources/prod/schema.sql similarity index 100% rename from backend/src/main/resources/schema.sql rename to backend/src/main/resources/prod/schema.sql diff --git a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java b/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java deleted file mode 100644 index 46a62050d..000000000 --- a/backend/src/test/java/com/codesquad/sidedish/SideDish/SideDishApplicationTests.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.codesquad.sidedish.SideDish; - - -import com.codesquad.sidedish.SideDish.domain.delivery.DishDelivery; -import com.codesquad.sidedish.SideDish.domain.dish.Dish; -import com.codesquad.sidedish.SideDish.domain.dish.DishRepository; -import com.codesquad.sidedish.SideDish.domain.image.DishImage; -import com.codesquad.sidedish.SideDish.domain.sale.DishSale; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.codesquad.sidedish.SideDish.domain.Category; -import com.codesquad.sidedish.SideDish.domain.CategoryRepository; -import org.assertj.core.api.SoftAssertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.Set; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; - - -@SpringBootTest -class SideDishApplicationTests { - - private Logger logger = LoggerFactory.getLogger(SideDishApplicationTests.class); - @Autowired - private CategoryRepository categoryRepository; - - @Test - @DisplayName("category 정보 테스트") - void readCategory() { - Long mainId = 1L; - Category main = categoryRepository.findById(mainId).get(); - logger.info("main {}", main.toString()); - - Long soupId = 2L; - Category soup = categoryRepository.findById(soupId).get(); - logger.info("soup {}", soup.toString()); - - Long sideId = 3L; - Category side = categoryRepository.findById(sideId).get(); - logger.info("side {}", side.toString()); - - checkNameAndEndPoint(main, "메인요리", "/main"); - checkNameAndEndPoint(soup, "국.찌개", "/soup"); - checkNameAndEndPoint(side, "반찬", "/side"); - } - - private void checkNameAndEndPoint(Category category, String name, String endPoint) { - assertThat(category.getCategoryName()).isEqualTo(name); - assertThat(category.getEndPoint()).isEqualTo(endPoint); - } - - @Autowired - private DishRepository dishRepository; - - @Test - @DisplayName("category 별로 생성된 dish의 개수 확인") - void countDish() { -// String hash1 = "HBDEF"; -// Dish dish1 = dishRepository.findByDetailHash(hash1); -// System.out.println(dish1.getCategoryId()); -// -// List mains = dishRepository.findAllByCategoryId(1L); -// System.out.println(mains.size()); - assertAll( - () -> assertEquals(8, dishRepository.countDishforCategoryId(1L)), - () -> assertEquals(8, dishRepository.countDishforCategoryId(2L)), - () -> assertEquals(8, dishRepository.countDishforCategoryId(3L)) - ); - } - - @Test - @DisplayName("dish 불러오기") - void readDish() { - Dish dish = dishRepository.findByDetailHash("HBBCC"); -// Set images = dish.getDishImages(); -// Set dishDeliveries = dish.getDishDeliveries(); -// Set dishSales = dish.getDishSales(); -// logger.info("images {}:", images); - - - - } - -} diff --git a/backend/src/test/java/com/codesquad/sidedish/SideDish/domain/CategoryRepositoryTest.java b/backend/src/test/java/com/codesquad/sidedish/SideDish/domain/CategoryRepositoryTest.java new file mode 100644 index 000000000..459959150 --- /dev/null +++ b/backend/src/test/java/com/codesquad/sidedish/SideDish/domain/CategoryRepositoryTest.java @@ -0,0 +1,47 @@ +package com.codesquad.sidedish.SideDish.domain; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +@Transactional +@SpringBootTest +@ActiveProfiles("dev") +class CategoryRepositoryTest { + + private Logger logger = LoggerFactory.getLogger(CategoryRepositoryTest.class); + @Autowired + private CategoryRepository categoryRepository; + + @Test + @DisplayName("category 정보 테스트") + void readCategory() { + Long mainId = 1L; + Category main = categoryRepository.findById(mainId).get(); + logger.info("main {}", main.toString()); + + Long soupId = 2L; + Category soup = categoryRepository.findById(soupId).get(); + logger.info("soup {}", soup.toString()); + + Long sideId = 3L; + Category side = categoryRepository.findById(sideId).get(); + logger.info("side {}", side.toString()); + + checkNameAndEndPoint(main, "메인요리", "/main"); + checkNameAndEndPoint(soup, "국.찌개", "/soup"); + checkNameAndEndPoint(side, "반찬", "/side"); + } + + private void checkNameAndEndPoint(Category category, String name, String endPoint) { + assertThat(category.getCategoryName()).isEqualTo(name); + assertThat(category.getEndPoint()).isEqualTo(endPoint); + } +} From a544477730c0b2dbb1c46c2894cff7b4300f39e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 16:36:43 +0900 Subject: [PATCH 11/18] =?UTF-8?q?feat:=20findAll=20=EC=9D=B4=20=EB=8F=99?= =?UTF-8?q?=EC=9E=91=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../SideDish/controller/DishController.java | 48 ++++----- .../sidedish/SideDish/domain/Dish.java | 96 ++++++++---------- .../sidedish/SideDish/domain/DishImage.java | 2 - .../sidedish/SideDish/dto/CategoryDto.java | 6 +- .../sidedish/SideDish/dto/DishDetailDto.java | 23 +++-- .../sidedish/SideDish/dto/DishDto.java | 24 +++-- .../sidedish/SideDish/dto/QuantityDto.java | 6 +- .../sidedish/SideDish/dto/RefreshDto.java | 6 +- .../SideDish/service/DishService.java | 62 ++++++----- .../main/resources/application-dev.properties | 2 +- 11 files changed, 135 insertions(+), 140 deletions(-) diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 1c675bd093320cfd4eadeb0e535330f0727531b7..816060a76e900bae715abdeaf321195e07b42ad1 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~jzf0RS;51K$7u literal 17 VcmZSX+g@Tc(fO$n0~jzJ1pqPW1fc)` diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java index 4c5068e24..23bef7545 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java @@ -1,13 +1,15 @@ package com.codesquad.sidedish.SideDish.controller; -import com.codesquad.sidedish.SideDish.dto.CategoryDto; -import com.codesquad.sidedish.SideDish.dto.DishDto; +import com.codesquad.sidedish.SideDish.dto.*; import com.codesquad.sidedish.SideDish.service.CategoryService; import com.codesquad.sidedish.SideDish.service.DishService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -30,27 +32,27 @@ public ResponseEntity> getCategories() { return ResponseEntity.ok().body(categories); } - // @GetMapping("/detail/{detailHash}") -// @ApiOperation(value = "요리 상세", notes = "요리의 상세 정보를 반환합니다.") -// public ResponseEntity getDetail(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { -// DishDetailDto dishDetailDto = dishService.getDetail(detailHash); -// return ResponseEntity.ok().body(dishDetailDto); -// } -// -// @GetMapping("/detail/{detailHash}/refreshable") -// @ApiOperation(value = "요리 상세 갱신", notes = "요리의 상세 정보를 갱신할 필요가 있는지 여부를 반환합니다.") -// public ResponseEntity getDetailRefreshable(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @ApiParam("프론트에서 마지막으로 업데이트 한 날짜. 데이터 형식: yyMMddhhmm") @RequestParam("lastUpdated") int lastUpdated) { -// RefreshDto refreshDto = dishService.getDetailRefreshable(detailHash, lastUpdated); -// return ResponseEntity.ok().body(refreshDto); -// } -// -// @GetMapping("/detail/{detailHash}/quantity") -// @ApiOperation(value = "요리 수량", notes = "요리의 주문 가능한 수량을 반환합니다.") -// public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { -// QuantityDto quantityDto = dishService.getDetailQuantity(detailHash); -// return ResponseEntity.ok().body(quantityDto); -// } -// + @GetMapping("/detail/{detailHash}") + @ApiOperation(value = "요리 상세", notes = "요리의 상세 정보를 반환합니다.") + public ResponseEntity getDetail(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { + DishDetailDto dishDetailDto = dishService.getDetail(detailHash); + return ResponseEntity.ok().body(dishDetailDto); + } + + @GetMapping("/detail/{detailHash}/refreshable") + @ApiOperation(value = "요리 상세 갱신", notes = "요리의 상세 정보를 갱신할 필요가 있는지 여부를 반환합니다.") + public ResponseEntity getDetailRefreshable(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @ApiParam("프론트에서 마지막으로 업데이트 한 날짜. 데이터 형식: yyMMddhhmm") @RequestParam("lastUpdated") int lastUpdated) { + RefreshDto refreshDto = dishService.getDetailRefreshable(detailHash, lastUpdated); + return ResponseEntity.ok().body(refreshDto); + } + + @GetMapping("/detail/{detailHash}/quantity") + @ApiOperation(value = "요리 수량", notes = "요리의 주문 가능한 수량을 반환합니다.") + public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash) { + QuantityDto quantityDto = dishService.getDetailQuantity(detailHash); + return ResponseEntity.ok().body(quantityDto); + } + @GetMapping("/main") @ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") public ResponseEntity> getMainList() { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index 3137b5af1..dd66e673c 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -1,6 +1,5 @@ package com.codesquad.sidedish.SideDish.domain; -import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.data.relational.core.mapping.Table; import java.time.LocalDateTime; @@ -14,22 +13,38 @@ public class Dish { private final String image; private final String title; private final String description; - private final int price; - private final int salePrice; - private final int point; + private final Integer price; + private final Integer salePrice; + private final Integer point; private final String deliveryInfo; - private final int deliveryFee; - private final long categoryId; - private final int quantity; + private final Integer deliveryFee; + private final Long categoryId; + private final Integer quantity; + private final LocalDateTime currentDateTime; + + private final Set sales = new HashSet<>(); + private final Set deliveries = new HashSet<>(); + private final Set images = new HashSet<>(); + + public void addSale(Sale... sales) { + for (Sale sale : sales) { + this.sales.add(sale); + } + } - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") - private LocalDateTime currentDateTime; + public void addDelivery(Delivery... deliveries) { + for (Delivery delivery : deliveries) { + this.deliveries.add(delivery); + } + } - private Set dishSales = new HashSet<>(); - private Set dishDeliveries = new HashSet<>(); - private Set dishImages = new HashSet<>(); + public void addImage(Image... images) { + for (Image image : images) { + this.images.add(image); + } + } - public Dish(String detailHash, String image, String title, String description, int price, int salePrice, int point, String deliveryInfo, int deliveryFee, long categoryId, int quantity) { + public Dish(String detailHash, String image, String title, String description, Integer price, Integer salePrice, Integer point, String deliveryInfo, Integer deliveryFee, Long categoryId, Integer quantity, LocalDateTime currentDateTime) { this.detailHash = detailHash; this.image = image; this.title = title; @@ -41,13 +56,7 @@ public Dish(String detailHash, String image, String title, String description, i this.deliveryFee = deliveryFee; this.categoryId = categoryId; this.quantity = quantity; - this.currentDateTime = LocalDateTime.now(); - } - - public void addImage(DishImage... dishImages) { - for (DishImage dishImage : dishImages) { - this.dishImages.add(dishImage); - } + this.currentDateTime = currentDateTime; } public String getDetailHash() { @@ -66,15 +75,15 @@ public String getDescription() { return description; } - public int getPrice() { + public Integer getPrice() { return price; } - public int getSalePrice() { + public Integer getSalePrice() { return salePrice; } - public int getPoint() { + public Integer getPoint() { return point; } @@ -82,50 +91,35 @@ public String getDeliveryInfo() { return deliveryInfo; } - public int getDeliveryFee() { + public Integer getDeliveryFee() { return deliveryFee; } - public long getCategoryId() { + public Long getCategoryId() { return categoryId; } - public int getQuantity() { + public Integer getQuantity() { return quantity; } - public Set getDishImages() { - return dishImages; + public LocalDateTime getCurrentDateTime() { + return currentDateTime; } - public Set getDishSales() { - return dishSales; + public Set getSales() { + return sales; } - public Set getDishDeliveries() { - return dishDeliveries; + public Set getDeliveries() { + return deliveries; } - public LocalDateTime getCurrentDateTime() { - return currentDateTime; + public Set getImages() { + return images; } - @Override - public String toString() { - return "Dish{" + - "detailHash='" + detailHash + '\'' + - ", image='" + image + '\'' + - ", title='" + title + '\'' + - ", description='" + description + '\'' + - ", price=" + price + - ", salePrice=" + salePrice + - ", point=" + point + - ", deliveryInfo='" + deliveryInfo + '\'' + - ", deliveryFee=" + deliveryFee + - ", categoryId=" + categoryId + - ", quantity=" + quantity + - ", currentDateTime=" + currentDateTime + - '}'; + public boolean refreshable(long lastUpdated) { + return false; } - } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java index 712e97c0d..37004fbc7 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java @@ -27,6 +27,4 @@ public String getDish() { public Long getImage() { return image; } - - } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/CategoryDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/CategoryDto.java index 5df022600..254ddbaa8 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/CategoryDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/CategoryDto.java @@ -3,11 +3,11 @@ import com.codesquad.sidedish.SideDish.domain.Category; public class CategoryDto { - private final long id; + private final Long id; private final String categoryName; private final String endPoint; - private CategoryDto(long id, String categoryName, String endPoint) { + private CategoryDto(Long id, String categoryName, String endPoint) { this.id = id; this.categoryName = categoryName; this.endPoint = endPoint; @@ -21,7 +21,7 @@ public static CategoryDto from(Category category) { ); } - public long getId() { + public Long getId() { return id; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java index 90485932e..aacc40a42 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java @@ -1,15 +1,16 @@ package com.codesquad.sidedish.SideDish.dto; import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.Image; -import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class DishDetailDto { private final List thumbImages; - private final int point; + private final Integer point; private final String deliveryInfo; - private int deliveryFee; + private Integer deliveryFee; private final List detailImages; private DishDetailDto(Builder builder) { @@ -22,19 +23,19 @@ private DishDetailDto(Builder builder) { public static DishDetailDto from(Dish dish) { return new Builder() - .thumbImages(Arrays.asList("", "")) // TODO: + .thumbImages(dish.getImages().stream().map(Image::getImageUrl).collect(Collectors.toList())) // TODO: .point(dish.getPoint()) .deliveryInfo(dish.getDeliveryInfo()) .deliveryFee(dish.getDeliveryFee()) - .detailImages(Arrays.asList("", "")) // TODO: + .detailImages(dish.getImages().stream().map(Image::getImageUrl).collect(Collectors.toList())) // TODO: .build(); } private static class Builder { private List thumbImages; - private int point; + private Integer point; private String deliveryInfo; - private int deliveryFee; + private Integer deliveryFee; private List detailImages; public DishDetailDto build() { @@ -47,7 +48,7 @@ public Builder thumbImages(List thumbImages) { return this; } - public Builder point(int point) { + public Builder point(Integer point) { this.point = point; return this; } @@ -57,7 +58,7 @@ public Builder deliveryInfo(String deliveryInfo) { return this; } - public Builder deliveryFee(int deliveryFee) { + public Builder deliveryFee(Integer deliveryFee) { this.deliveryFee = deliveryFee; return this; } @@ -72,7 +73,7 @@ public List getThumbImages() { return thumbImages; } - public int getPoint() { + public Integer getPoint() { return point; } @@ -80,7 +81,7 @@ public String getDeliveryInfo() { return deliveryInfo; } - public int getDeliveryFee() { + public Integer getDeliveryFee() { return deliveryFee; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java index 837ebe3c7..1cf5823de 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java @@ -1,10 +1,12 @@ package com.codesquad.sidedish.SideDish.dto; +import com.codesquad.sidedish.SideDish.domain.Delivery; import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.Sale; -import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class DishDto { private final String detailHash; @@ -12,8 +14,8 @@ public class DishDto { private final String title; private final String description; private final List deliveryTypes; - private final int price; - private final int salePrice; + private final Integer price; + private final Integer salePrice; private final List badges; private DishDto(Builder builder) { @@ -33,10 +35,10 @@ public static DishDto from(Dish dish) { .image(dish.getImage()) .title(dish.getTitle()) .description(dish.getDescription()) - .deliveryTypes(Arrays.asList("", "")) // TODO: + .deliveryTypes(dish.getDeliveries().stream().map(Delivery::getDeliveryType).collect(Collectors.toList())) .price(dish.getPrice()) .salePrice(dish.getSalePrice()) - .badges(Arrays.asList("", "")) // TODO: + .badges(dish.getSales().stream().map(Sale::getBadge).collect(Collectors.toList())) .build(); } @@ -46,8 +48,8 @@ public static class Builder { private String title; private String description; private List deliveryTypes; - private int price; - private int salePrice; + private Integer price; + private Integer salePrice; private List badges; public DishDto build() { @@ -80,12 +82,12 @@ public Builder deliveryTypes(List deliveryTypes) { return this; } - public Builder price(int price) { + public Builder price(Integer price) { this.price = price; return this; } - public Builder salePrice(int salePrice) { + public Builder salePrice(Integer salePrice) { this.salePrice = salePrice; return this; } @@ -116,11 +118,11 @@ public String getDescription() { return description; } - public int getPrice() { + public Integer getPrice() { return price; } - public int getSalePrice() { + public Integer getSalePrice() { return salePrice; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java index 915e50a05..93358ba11 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/QuantityDto.java @@ -4,13 +4,13 @@ import com.codesquad.sidedish.SideDish.domain.Dish; public class QuantityDto { - private final int quantity; + private final Integer quantity; - private QuantityDto(int quantity) { + private QuantityDto(Integer quantity) { this.quantity = quantity; } - public int getQuantity() { + public Integer getQuantity() { return quantity; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/RefreshDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/RefreshDto.java index 9fc67a500..a093d7f58 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/RefreshDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/RefreshDto.java @@ -1,13 +1,13 @@ package com.codesquad.sidedish.SideDish.dto; public class RefreshDto { - private final boolean refreshable; + private final Boolean refreshable; - public RefreshDto(boolean refreshable) { + public RefreshDto(Boolean refreshable) { this.refreshable = refreshable; } - public boolean isRefreshable() { + public Boolean isRefreshable() { return refreshable; } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 6d99075dc..3d0206492 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -2,11 +2,16 @@ import com.codesquad.sidedish.SideDish.domain.Dish; import com.codesquad.sidedish.SideDish.domain.DishRepository; +import com.codesquad.sidedish.SideDish.dto.DishDetailDto; import com.codesquad.sidedish.SideDish.dto.DishDto; +import com.codesquad.sidedish.SideDish.dto.QuantityDto; +import com.codesquad.sidedish.SideDish.dto.RefreshDto; +import com.codesquad.sidedish.SideDish.exception.DishNotFoundException; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @Service public class DishService { @@ -17,41 +22,34 @@ public DishService(DishRepository dishRepository) { } public List getList(Long categoryId) { - List dishDtos = new ArrayList<>(); - for (Dish dish : dishRepository.findAll()) { - dishDtos.add(DishDto.from(dish)); - } - return dishDtos; + return dishRepository.findAllByCategoryId(categoryId) + .stream().map(DishDto::from) + .collect(Collectors.toList()); } - // public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { -// Dish dish = dishRepository.findByDetailHash(detailHash); -// boolean refreshable = dish.refreshable(lastUpdated); -// return new RefreshDto(refreshable); -// } -// -// public QuantityDto getDetailQuantity(String detailHash) { -// return QuantityDto.from(getDish(detailHash)); -// } -// -// public DishDetailDto getDetail(String detailHash) { -// Dish dish = dishRepository.findByDetailHash(detailHash); -// List tumb = imageRepository.findImagesByType("thum"); -// List detail = imageRepository.findImagesByType("detail"); -// DishDetailDto dishDetailDto = new DishDetailDto(dish, tumb, detail); -// return dishDetailDto; -// } -//// + public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { + Dish dish = dishRepository.findByDetailHash(detailHash); + boolean refreshable = dish.refreshable(lastUpdated); + return new RefreshDto(refreshable); + } -// private Dish getDish(String detailHash) { -// Dish dish = dishRepository.findByDetailHash(detailHash); -// return Optional.ofNullable(dish) -// .orElseThrow(() -> new DishNotFoundException(detailHash)); -// } + public QuantityDto getDetailQuantity(String detailHash) { + return QuantityDto.from(getDish(detailHash)); + } -// public List getList(Long categoryId) { -// return dishRepository.findAllByCategoryId(categoryId); -// } + // + public DishDetailDto getDetail(String detailHash) { + Dish dish = dishRepository.findByDetailHash(detailHash); +// List tumb = imageRepository.findImagesByType("thum"); +// List detail = imageRepository.findImagesByType("detail"); + return DishDetailDto.from(dish); + } +// + private Dish getDish(String detailHash) { + Dish dish = dishRepository.findByDetailHash(detailHash); + return Optional.ofNullable(dish) + .orElseThrow(() -> new DishNotFoundException(detailHash)); + } } diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties index 999edc71d..78aa7200b 100644 --- a/backend/src/main/resources/application-dev.properties +++ b/backend/src/main/resources/application-dev.properties @@ -3,7 +3,7 @@ spring.config.import=classpath:common.properties # h2 관련 설정 spring.datasource.driver-class-name=org.h2.Driver spring.datasource.initialization-mode=always -spring.datasource.url=jdbc:h2:~/test;MODE=MySQL;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.url=jdbc:h2:~/test;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE;SCHEMA=sidedish spring.datasource.schema=classpath:dev/schema-h2.sql spring.datasource.username=sa spring.datasource.password= From a779680befc87f7917fc7cff4383a97bb7ef5991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 20:06:12 +0900 Subject: [PATCH 12/18] =?UTF-8?q?refactor:=20Query=20=EB=A5=BC=20=ED=86=B5?= =?UTF-8?q?=ED=95=B4=20dish=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../SideDish/domain/CategoryRepository.java | 3 + .../SideDish/domain/DeliveryRepository.java | 7 + .../sidedish/SideDish/domain/Dish.java | 51 ++-- .../SideDish/domain/DishRepository.java | 5 +- .../SideDish/domain/ImageRepository.java | 7 + .../SideDish/domain/SaleRepository.java | 7 + .../main/resources/application-dev.properties | 2 +- backend/src/main/resources/prod/schema.sql | 223 +++++++++++++++++- 9 files changed, 262 insertions(+), 43 deletions(-) create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 816060a76e900bae715abdeaf321195e07b42ad1..1044d5af13f6643d8aba4a106257317cfd19e7cd 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~j#70RS;<1S0?d literal 17 VcmZSX+g@Tc(fO$n0~jzf0RS;51K$7u diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java index 17311be6d..281dbb5e1 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/CategoryRepository.java @@ -1,9 +1,12 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; import java.util.List; public interface CategoryRepository extends CrudRepository { + @Override + @Query("SELECT * from sidedish.category") List findAll(); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java new file mode 100644 index 000000000..a258a21fc --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java @@ -0,0 +1,7 @@ +package com.codesquad.sidedish.SideDish.domain; + +import org.springframework.data.repository.CrudRepository; + +public interface DeliveryRepository extends CrudRepository { +// List findAllByDishDetailHash(String dishDetailHash); +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index dd66e673c..18489f97b 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -1,12 +1,9 @@ package com.codesquad.sidedish.SideDish.domain; -import org.springframework.data.relational.core.mapping.Table; - import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; -@Table("DISH") public class Dish { private final String detailHash; @@ -22,27 +19,27 @@ public class Dish { private final Integer quantity; private final LocalDateTime currentDateTime; - private final Set sales = new HashSet<>(); - private final Set deliveries = new HashSet<>(); - private final Set images = new HashSet<>(); - - public void addSale(Sale... sales) { - for (Sale sale : sales) { - this.sales.add(sale); - } - } - - public void addDelivery(Delivery... deliveries) { - for (Delivery delivery : deliveries) { - this.deliveries.add(delivery); - } - } - - public void addImage(Image... images) { - for (Image image : images) { - this.images.add(image); - } - } +// private final Set sales = new HashSet<>(); +// private final Set deliveries = new HashSet<>(); +// private final Set images = new HashSet<>(); + +// public void addSale(Sale... sales) { +// for (Sale sale : sales) { +// this.sales.add(sale); +// } +// } +// +// public void addDelivery(Delivery... deliveries) { +// for (Delivery delivery : deliveries) { +// this.deliveries.add(delivery); +// } +// } +// +// public void addImage(Image... images) { +// for (Image image : images) { +// this.images.add(image); +// } +// } public Dish(String detailHash, String image, String title, String description, Integer price, Integer salePrice, Integer point, String deliveryInfo, Integer deliveryFee, Long categoryId, Integer quantity, LocalDateTime currentDateTime) { this.detailHash = detailHash; @@ -108,15 +105,15 @@ public LocalDateTime getCurrentDateTime() { } public Set getSales() { - return sales; + return new HashSet<>(); } public Set getDeliveries() { - return deliveries; + return new HashSet<>(); } public Set getImages() { - return images; + return new HashSet<>(); } public boolean refreshable(long lastUpdated) { diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java index 8554b96d9..18e8088ca 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java @@ -6,10 +6,9 @@ import java.util.List; public interface DishRepository extends CrudRepository { + @Query("SELECT * from sidedish.dish WHERE dish.category_id = :categoryId") List findAllByCategoryId(Long categoryId); + @Query("SELECT * from sidedish.dish WHERE dish.detail_hash = :detailHash") Dish findByDetailHash(String detailHash); - - @Query("select count(*) from DISH where dish.category_id = :categoryId") - int countDishforCategoryId(Long categoryId); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java new file mode 100644 index 000000000..0e18e4f2b --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java @@ -0,0 +1,7 @@ +package com.codesquad.sidedish.SideDish.domain; + +import org.springframework.data.repository.CrudRepository; + +public interface ImageRepository extends CrudRepository { +// List findAllByDishDetailHash(String dishDetailHash); +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java new file mode 100644 index 000000000..478ca4811 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java @@ -0,0 +1,7 @@ +package com.codesquad.sidedish.SideDish.domain; + +import org.springframework.data.repository.CrudRepository; + +public interface SaleRepository extends CrudRepository { +// List findAllByDishDetailHash(String dishDetailHash); +} diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties index 78aa7200b..37e8ba34c 100644 --- a/backend/src/main/resources/application-dev.properties +++ b/backend/src/main/resources/application-dev.properties @@ -3,7 +3,7 @@ spring.config.import=classpath:common.properties # h2 관련 설정 spring.datasource.driver-class-name=org.h2.Driver spring.datasource.initialization-mode=always -spring.datasource.url=jdbc:h2:~/test;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE;SCHEMA=sidedish +spring.datasource.url=jdbc:h2:~/test;DB_CLOSE_DELAY=- 1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE spring.datasource.schema=classpath:dev/schema-h2.sql spring.datasource.username=sa spring.datasource.password= diff --git a/backend/src/main/resources/prod/schema.sql b/backend/src/main/resources/prod/schema.sql index 1683f6410..584ad1b3b 100644 --- a/backend/src/main/resources/prod/schema.sql +++ b/backend/src/main/resources/prod/schema.sql @@ -138,18 +138,217 @@ CREATE TABLE IF NOT EXISTS `sidedish`.`dish_image`( ); +INSERT INTO sidedish.category + (id, category_name, end_point) +VALUES + (1, '메인요리', '/main'), + (2, '국.찌개', '/soup'), + (3, '반찬', '/side'); + + +INSERT INTO sidedish.dish + (detail_hash, image, title, description, price, sale_price,point, delivery_info, delivery_fee, category_id, quantity) +VALUES + ('HBDEF', 'http://public.codesquad.kr/jk/storeapp/data/2d3f99a9a35601f4e98837bc4d39b2c8.jpg', '[미노리키친] 규동 250g', '일본인의 소울푸드! 한국인도 좋아하는 소고기덮밥', 6000, 5200, 52,'서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HDF73', 'http://public.codesquad.kr/jk/storeapp/data/7674311a02ba7c88675f3186ddaeef9e.jpg', '[빅마마의밥친구] 아삭 고소한 연근고기조림 250g', '편식하는 아이도 좋아하는 건강한 연근조림', 5500, null, 55, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HF778', 'http://public.codesquad.kr/jk/storeapp/data/cad8eee316cf7151e07638aa57b32a9d.jpg', '[소중한식사] 골뱅이무침 195g', '매콤새콤달콤, 반찬으로도 안주로도 좋은', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HFB53', 'http://public.codesquad.kr/jk/storeapp/data/b6beada6b89af950289003d929936d9c.jpg', '[옹가솜씨] 꽁치간장조림 240g', '[옹가솜씨] 꽁치간장조림 240g', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H077F', 'http://public.codesquad.kr/jk/storeapp/data/0221110ead70dfd455e40703bbdd6252.jpg', '[마더앤찬] 코다리구이 320g', '큼지막하고 살집 많은 동태 한 마리로 만든 코다리구이입니다.', 7500, 6750, 67, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H4665', 'http://public.codesquad.kr/jk/storeapp/data/385f4106ac26f6e4fe7c640714f405a5.jpg', '[남도애꽃] 반건조 문어조림 120g', '씹을수록 감칠맛나는 문어살의 쫄깃함', 4600, null, 46, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('H1AA9', 'http://public.codesquad.kr/jk/storeapp/data/2455226945d52f5aefd51f35d663bb16.jpg', '[마샐미디쉬] 매콤마늘쫑 해산물볶음 180g', '탱글탱글한 새우와 오징어를 마늘쫑과 함께 매콤하게 볶아냈어요.', 6900, 6210, 62, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + ('HEDFB', 'http://public.codesquad.kr/jk/storeapp/data/bc3b777115e8377a48c7bd762fe5fdc9.jpg', '[빅마마의밥친구] 비빔오징어 150g', '달콤한 신야초발효액이 포인트!', 5000, null, 50, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 1, 5), + + ('H72C3', 'http://public.codesquad.kr/jk/storeapp/data/d1fccf125f0a78113d0e06cb888f2e74.jpg', '[수하동] 특곰탕 850g', '100% 한우양지로 끓여낸 70년전통의 서울식곰탕', 15000, 14200, 142, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HA6EE', 'http://public.codesquad.kr/jk/storeapp/data/c069bc32cb37727c59e1f0c2839311a0.jpg', '[빅마마의밥친구] 된장찌개 900g', '항아리에서 숙성시킨 집된장으로만 맛을내 짜지 않은 된장찌개', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H8CD0', 'http://public.codesquad.kr/jk/storeapp/data/f31fc3f5828c27ff60e4cf89a862d31c.jpg', '[탐나는밥상] 동태탕 1000g', '칼칼한 국물이 속 풀기에 딱 좋은 동태탕', 14000, null, 140, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HE2E9', 'http://public.codesquad.kr/jk/storeapp/data/6edbb16da52708e8533b85fbf743f882.jpg', '[국물닷컴] 치즈부대찌개 600g', '안주용 부대찌개와는 달라 밥말아먹기 딱 좋은', 4300, null, 43, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HAA47', 'http://public.codesquad.kr/jk/storeapp/data/892f3e7f043bfa7dbbcd58f88eecac36.jpg', '[집밥의완성] 스키야키 1.5kg (2~3인분)', '진한 풍미의 일본식 전골, 스키야키', 10000, null, 100, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H3254', 'http://public.codesquad.kr/jk/storeapp/data/ae571e13d18fd4f0f40d685d2c8fe8f1.jpg', '[새로미부산어묵] 프리미엄 어묵탕세트', '밀가루 0% 프리미엄 어묵에 어묵스프까지 드려요!', 18000, 14400, 144, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('H26C7', 'http://public.codesquad.kr/jk/storeapp/data/8fd330b5f5dbccbcbf4f5731e5e9e29b.jpg', '[모이세] 육개장 1팩(600g)', '제주3대해장국 맛집의 인기메뉴', 5000, 4400, 44, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + ('HFFF9', 'http://public.codesquad.kr/jk/storeapp/data/2416b58044d49f0d3a24256f8e76163b.jpg', '[마더앤찬] 명란감자국 630ml', '간간한 저염명란과 고소한 감자가 조화로운 국이에요', 7000, 6300, 63, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 2, 5), + + ('HBBCC', 'http://public.codesquad.kr/jk/storeapp/data/fdb0d5fcfb86e332505785225a6d9ade.jpg', '[마샐미디쉬] 유자소스 연근무침 250g', '향긋한 유자향과 아삭한 연근', 6500, null, 65, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H1939', 'http://public.codesquad.kr/jk/storeapp/data/e5646e5fc09a01a9243979b229e0572b.jpg', '[동네부엌] 쇠고기야채장조림 200g', '부드러운 고기부터 밥비벼먹기 딱좋은 국물까지', 7400, null, 74, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H8EA5', 'http://public.codesquad.kr/jk/storeapp/data/4cfd1954861ebd18b5b53e558a8e902e.jpg', '[소중한식사] 도라지초무침 150g', '새콤달콤 입맛 돋우는', 4000, null, 40, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H602F', 'http://public.codesquad.kr/jk/storeapp/data/422befe07f7e2860b9a83a8d7049ec2e.jpg', '[미노리키친] 일본식 우엉조림(킨피라고보) 80g', '한국식 우엉조림과는 다른 진한 감칠맛', 3300, null, 33, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + + ('H9F0B', 'http://public.codesquad.kr/jk/storeapp/data/d0b5d2be962947d9534e2140d1b34b2d.jpg', '[빅마마의밥친구] 갈치포무침 150g', '쉽게 접할수 없는 꼬순내가득 갈치포 무침', 7000, null, 70, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('H0FC6', 'http://public.codesquad.kr/jk/storeapp/data/f6817349118d4c671da8dca9065649a9.jpg', '[마더앤찬] 명란치즈계란말이 230g', '아이반찬으로 최고 계란말이', 3870, null, 38, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HCCFE', 'http://public.codesquad.kr/jk/storeapp/data/757878b14ee5a8d5af905c154fc38f01.jpg', '[옹가솜씨] 달걀곤약조림 330g', '칼로리 부담 쭉쭉 내린', 5800, null, 58, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5), + ('HB9C1', 'http://public.codesquad.kr/jk/storeapp/data/043cf496f07899e7515f761e29d1ffa9.jpg', '[너의반찬] 미소된장 고추무침 200g', '고소한 양념 때문에 손이 자꾸 가요', 4500, null, 45, '서울 경기 새벽배송 / 전국택배 (제주 및 도서산간 불가)' ,2500, 3, 5); + +INSERT INTO sidedish.image + (id, image_url, type) +VALUES + (1, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4cce011a4a352c22cd399a60271b4921.jpg', 'thumb'), + (2, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/6ef14155afc5b47e8c9efd762f7a6096.jpg', 'thumb'), + (3, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/8744504ff3bc315f901dca1f26fe63a1.jpg', 'thumb'), + (4, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/e30bd6de9340fc05db3cd1d1329b2c56.jpg', 'thumb'), + (5, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/9c2c53b40a11b79c90549a058c2da4b7.jpg', 'detail'), + (6, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/70b0c77d3ef5cdd6269588685bbefe43.jpg', 'detail'), + (7, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/72f1049b047f65f42a267d5bbd1e6204.jpg', 'detail'), + (8, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/768afd17faa8bf3461b8160ba0aa26bf.jpg', 'detail'), + (9, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/95816f09d3294641f2e0feacaa739991.jpg', 'detail'), + (10, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/2450219a4686d9d6d579fc04020929b4.jpg', 'detail'), + (11, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/4971475295545ec336c9479fabb25364.jpg', 'detail'), + (12, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/a8c434715709fe855f3ea1554ec362b6.jpg', 'detail'), + (13, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/b2b3d0d2107ab91b16e0eb804cd84bc9.jpg', 'detail'), + (14, 'http://public.codesquad.kr/jk/storeapp/data/detail/HBDEF/c0dd6887c9d9368604fc70d7fc3c4598.jpg', 'detail'), + + (15, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0f95f44ea8e2e7930321def493753a48.jpg', 'thumb'), + (16, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/2d408898494ac950d7d2cfd6c36d59c2.jpg', 'thumb'), + (17, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/62c8bb77facfc9c3be81f9bf45b27f2a.jpg', 'thumb'), + (18, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/f6d73afc0ebc1efa71eaea32e9d846f2.jpg', 'thumb'), + (19, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (20, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/5f73c5c80b62ef63c8a8eecefe32fc29.jpg', 'detail'), + (21, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/9bd9158fb5ffbc46708b7928ee50708e.jpg', 'detail'), + (22, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0253cdebc4972fefd6b94458024fe765.jpg', 'detail'), + (23, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/3299da0677b50c8c519adc0335271c49.jpg', 'detail'), + (24, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/0642265b65dcc2490ab164ff428cbfe2.jpg', 'detail'), + (25, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/695683493c1ae475a175475f50d3259f.jpg', 'detail'), + (26, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/c8f9bed4f5c07585b869e3d171904a93.jpg', 'detail'), + (27, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d2e3274c95c832bc9bfbcebbd548f61b.jpg', 'detail'), + (28, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d9e4fa00652483d74b46317d38159a2f.jpg', 'detail'), + (29, 'http://public.codesquad.kr/jk/storeapp/data/detail/HDF73/d7799b67683128642453f9e2b4c8ce84.jpg', 'detail'), + + + (30, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/4e96f386d5a5c4459bc0ac6ffd0c1fce.jpg', 'thumb'), + (31, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/00327d0df92e29bad02e7387349bed53.jpg', 'thumb'), + (32, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/781fea32c56eb102429902a2f62cbaf3.jpg', 'thumb'), + (33, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/edd7a54096d6df1b8bc8b318cea0191c.jpg', 'detail'), + (34, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/fb8e6e21faa8284021c1b1c7a1ae1281.jpg', 'detail'), + (35, 'http://public.codesquad.kr/jk/storeapp/data/detail/HAA47/36a0566d2fb69a4bcea946727181836d.jpg', 'detail'), + + (36, 'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/2ad963a9f63d371826748c852a0025c3.jpg', 'thumb'), + (37,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/f945d8ac1dccc3f931bcaf35de5de582.jpg', 'thumb'), + (38,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/bacb0b8186371bfafbd92dbeec718e13.jpg', 'thumb'), + (39,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b96b02e9a956c6d5ad1e10eb14ba81e0.jpg', 'thumb'), + (40,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/3d67aabd2751620367e1d1ac3e3d7ef2.jpg', 'detail'), + (41,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/855b42b4e80162e6930f06aa80bd1272.jpg', 'detail'), + (42,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/1966de56cf138639d5d50d4bf2db8e72.jpg', 'detail'), + (43,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b3dd54082745d1188f3a6e582e7cd993.jpg', 'detail'), + (44,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/4a6fd1fd1116c14aa6aef5e6851ab6a9.jpg', 'detail'), + (45,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/7e12275d669102d0269278a7c91ab49d.jpg', 'detail'), + (46,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/ab34ea3755f59a21662266eb62b7bc4b.jpg', 'detail'), + (47,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/b0a70ff59a3b5360b6246b507693c4d4.jpg', 'detail'), + (48,'http://public.codesquad.kr/jk/storeapp/data/detail/H26C7/dc772923b4a2e053f1baf68fa28a48ee.jpg', 'detail'), + + (49, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c8c8045696b4692107ef28c8b445ca42.jpg', 'thumb'), + (50, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/edc6bae2e2663f05b4e8eb5a2b95d68f.jpg', 'thumb'), + (51, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c935f5913dc66b11ebceeef85485c438.jpg', 'thumb'), + (52, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/7c1e24867611394f04b37d05593e21ba.jpg', 'thumb'), + (53, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/670e7deefe1d84a4f4e058655fbd4d7c.jpg', 'detail'), + (54, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/1898cda038e92454395b8ffca8cd4393.jpg', 'detail'), + (55, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49516d302dad870fbdd75cf98a01eae4.jpg', 'detail'), + (56, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/c1bb6fe4f72fcea27ea989ae48c61c86.jpg', 'detail'), + (57, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/49afed8d3ec417b39ce8de456fc6661c.jpg', 'detail'), + (58, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/e62762e63f3e12dc2857a065badf1eea.jpg', 'detail'), + (59, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/31103ab946bff52b709ec6891e768c05.jpg', 'detail'), + (60, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/f84dc16f4f6d97661bd13d587a72d6b1.jpg', 'detail'), + (61, 'http://public.codesquad.kr/jk/storeapp/data/detail/H602F/fd3f49614f731a0610a5409c0deb3c60.jpg', 'detail'), + + (62, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/43c38eeffa556554c9b06301eb3e85b2.jpg', 'thumb'), + (63, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/92f556b605c4a84813070d7214c4f336.jpg', 'thumb'), + (64, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/538b8ab021c7814aa4af860d94f81287.jpg', 'thumb'), + (65, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/adaef08ab0680b087096afa0f0070fad.jpg', 'thumb'), + (66, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/341b8605fa224ec1808c4f169097d170.jpg', 'detail'), + (67, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/0228d4cb660a3cca06952917bd024dcb.jpg', 'detail'), + (68, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e027227f61a93b6473e8c4bbd5c3de74.jpg', 'detail'), + (69, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/03ac0b09199421bb61727c667c2361f6.jpg', 'detail'), + (70, 'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/cbe4a3e12b7bdba5cf410e0e19dcf1ca.jpg', 'detail'), + (71,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/b58fa5791b67db106524b48442cb1c6a.jpg', 'detail'), + (72,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/82cfe0332f0e1c927a23b79f1d152430.jpg', 'detail'), + (73,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/390ca9ad5a574cbe7f3f6e26871f6690.jpg', 'detail'), + (74,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/e113889a6120357c8e6196802a9f155b.jpg', 'detail'), + (75,'http://public.codesquad.kr/jk/storeapp/data/detail/H0FC6/967e8e1ef357e9722b796e2bcb09ba3d.jpg', 'detail'); + +INSERT INTO sidedish.dish_image + (dish, image) +values + ('HBDEF', 1),('HBDEF', 2),('HBDEF', 3),('HBDEF', 4),('HBDEF', 5),('HBDEF', 6),('HBDEF', 7),('HBDEF', 8),('HBDEF', 9),('HBDEF', 10),('HBDEF', 11),('HBDEF', 12),('HBDEF', 13),('HBDEF', 14), + ('HDF73', 15),('HDF73', 16),('HDF73', 17),('HDF73', 18),('HDF73', 19),('HDF73', 20),('HDF73', 21),('HDF73', 22),('HDF73', 23),('HDF73', 24),('HDF73', 25),('HDF73', 26),('HDF73', 27),('HDF73', 28),('HDF73', 29), + ('HF778', 1),('HF778', 2),('HF778', 3),('HF778', 4),('HF778', 5),('HF778', 6),('HF778', 7),('HF778', 8),('HF778', 9),('HF778', 10),('HF778', 11),('HF778', 12),('HF778', 13),('HF778', 14), + ('HFB53', 1),('HFB53', 2),('HFB53', 3),('HFB53', 4),('HFB53', 5),('HFB53', 6),('HFB53', 7),('HFB53', 8),('HFB53', 9),('HFB53', 10),('HFB53', 11),('HFB53', 12),('HFB53', 13),('HFB53', 14), + ('H077F', 1),('H077F', 2),('H077F', 3),('H077F', 4),('H077F', 5),('H077F', 6),('H077F', 7),('H077F', 8),('H077F', 9),('H077F', 10),('H077F', 11),('H077F', 12),('H077F', 13),('H077F', 14), + ('H4665', 15),('H4665', 16),('H4665', 17),('H4665', 18),('H4665', 19),('H4665', 20),('H4665', 21),('H4665', 22),('H4665', 23),('H4665', 24),('H4665', 25),('H4665', 26),('H4665', 27),('H4665', 28),('H4665', 29), + ('H1AA9', 15),('H1AA9', 16),('H1AA9', 17),('H1AA9', 18),('H1AA9', 19),('H1AA9', 20),('H1AA9', 21),('H1AA9', 22),('H1AA9', 23),('H1AA9', 24),('H1AA9', 25),('H1AA9', 26),('H1AA9', 27),('H1AA9', 28),('H1AA9', 29), + ('HEDFB', 15),('HEDFB', 16),('HEDFB', 17),('HEDFB', 18),('HEDFB', 19),('HEDFB', 20),('HEDFB', 21),('HEDFB', 22),('HEDFB', 23),('HEDFB', 24),('HEDFB', 25),('HEDFB', 26),('HEDFB', 27),('HEDFB', 28),('HEDFB', 29), + + ('H72C3', 30),('H72C3', 31),('H72C3', 32),('H72C3', 33),('H72C3', 34),('H72C3', 35), + ('HA6EE', 30),('HA6EE', 31),('HA6EE', 32),('HA6EE', 33),('HA6EE', 34),('HA6EE', 35), + ('H8CD0', 30),('H8CD0', 31),('H8CD0', 32),('H8CD0', 33),('H8CD0', 34),('H8CD0', 35), + ('HE2E9', 30),('HE2E9', 31),('HE2E9', 32),('HE2E9', 33),('HE2E9', 34),('HE2E9', 35), + ('HAA47', 30),('HAA47', 31),('HAA47', 32),('HAA47', 33),('HAA47', 34),('HAA47', 35), + ('H3254', 36),('H3254', 37),('H3254', 38),('H3254', 39),('H3254', 40),('H3254', 41),('H3254', 42),('H3254', 43),('H3254', 44),('H3254', 45),('H3254', 46),('H3254', 47),('H3254', 48), + ('H26C7', 36),('H26C7', 37),('H26C7', 38),('H26C7', 39),('H26C7', 40),('H26C7', 41),('H26C7', 42),('H26C7', 43),('H26C7', 44),('H26C7', 45),('H26C7', 46),('H26C7', 47),('H26C7', 48), + ('HFFF9', 36),('HFFF9', 37),('HFFF9', 38),('HFFF9', 39),('HFFF9', 40),('HFFF9', 41),('HFFF9', 42),('HFFF9', 43),('HFFF9', 44),('HFFF9', 45),('HFFF9', 46),('HFFF9', 47),('HFFF9', 48), + + ('HBBCC', 49),('HBBCC', 50),('HBBCC', 51),('HBBCC', 52),('HBBCC', 53),('HBBCC', 54),('HBBCC', 55),('HBBCC', 56),('HBBCC', 57),('HBBCC', 58),('HBBCC', 59),('HBBCC', 60),('HBBCC', 61), + ('H1939', 49),('H1939', 50),('H1939', 51),('H1939', 52),('H1939', 53),('H1939', 54),('H1939', 55),('H1939', 56),('H1939', 57),('H1939', 58),('H1939', 59),('H1939', 60),('H1939', 61), + ('H8EA5', 49),('H8EA5', 50),('H8EA5', 51),('H8EA5', 52),('H8EA5', 53),('H8EA5', 54),('H8EA5', 55),('H8EA5', 56),('H8EA5', 57),('H8EA5', 58),('H8EA5', 59),('H8EA5', 60),('H8EA5', 61), + ('H602F', 49),('H602F', 50),('H602F', 51),('H602F', 52),('H602F', 53),('H602F', 54),('H602F', 55),('H602F', 56),('H602F', 57),('H602F', 58),('H602F', 59),('H602F', 60),('H602F', 61), + ('H9F0B', 62),('H9F0B', 63),('H9F0B', 64),('H9F0B', 65),('H9F0B', 66),('H9F0B', 67),('H9F0B', 68),('H9F0B', 69),('H9F0B', 70),('H9F0B', 71),('H9F0B', 72),('H9F0B', 73),('H9F0B', 74),('H9F0B', 75), + ('H0FC6', 62),('H0FC6', 63),('H0FC6', 64),('H0FC6', 65),('H0FC6', 66),('H0FC6', 67),('H0FC6', 68),('H0FC6', 69),('H0FC6', 70),('H0FC6', 71),('H0FC6', 72),('H0FC6', 73),('H0FC6', 74),('H0FC6', 75), + ('HCCFE', 62),('HCCFE', 63),('HCCFE', 64),('HCCFE', 65),('HCCFE', 66),('HCCFE', 67),('HCCFE', 68),('HCCFE', 69),('HCCFE', 70),('HCCFE', 71),('HCCFE', 72),('HCCFE', 73),('HCCFE', 74),('HCCFE', 75), + ('HB9C1', 62),('HB9C1', 63),('HB9C1', 64),('HB9C1', 65),('HB9C1', 66),('HB9C1', 67),('HB9C1', 68),('HB9C1', 69),('HB9C1', 70),('HB9C1', 71),('HB9C1', 72),('HB9C1', 73),('HB9C1', 74),('HB9C1', 75); + +INSERT INTO sidedish.sale + (id, badge, sale_type, sale_value) +VALUES + (1, '이벤트특가', 'percentage', 10), + (2, '런칭특가', 'minus', 1000); + +INSERT INTO sidedish.dish_sale + (dish, sale) +VALUES + ('HBDEF', 1), + ('HF778', 1), + ('H077F', 1), + ('H1AA9', 1), + ('H72C3', 1), + ('H72C3', 2), + ('H3254', 1), + ('H3254', 2), + ('H26C7', 1), + ('H26C7', 2), + ('HFFF9', 1), + ('HFFF9', 2); + +INSERT INTO sidedish.delivery + (id, delivery_type) +VALUES + (1, '새벽배송'), + (2, '전국택배'); + +INSERT INTO sidedish.dish_delivery + (dish, delivery) +VALUES + ('HBDEF', 1), ('HBDEF', 2), + ('HDF73', 1), ('HDF73', 2), + ('HF778', 1), ('HF778', 2), + ('HFB53', 1),('HFB53', 2), + ('H077F', 1),('H077F', 2), + ('H4665', 1),('H4665', 2), + ('H1AA9', 1),('H1AA9', 2), + ('HEDFB', 1),('HEDFB', 2), + ('H72C3', 1),('H72C3', 2), + ('HA6EE', 1),('HA6EE', 2), + ('H8CD0', 1),('H8CD0', 2), + ('HE2E9', 1),('HE2E9', 2), + ('HAA47', 1),('HAA47', 2), + ('H3254', 1),('H3254', 2), + ('H26C7', 1),('H26C7', 2), + ('HFFF9', 1),('HFFF9', 2), + ('HBBCC', 1),('HBBCC', 2), + ('H1939', 1),('H1939', 2), + ('H8EA5', 1),('H8EA5', 2), + ('H602F', 1),('H602F', 2), + ('H9F0B', 1),('H9F0B', 2), + ('H0FC6', 1),('H0FC6', 2), + ('HCCFE', 1),('HCCFE', 2), + ('HB9C1', 1),('HB9C1', 2); + + SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; - - - - - - - - - - - - From 4172f102f48939c5522b90cf4fcd3a532096503c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 23:27:55 +0900 Subject: [PATCH 13/18] =?UTF-8?q?feat:=20dishDetail=20=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=AA=A9=EB=A1=9D=EC=9D=B4=20?= =?UTF-8?q?=EB=82=98=EC=98=A4=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../sidedish/SideDish/domain/Delivery.java | 13 ------- .../sidedish/SideDish/domain/Dish.java | 36 ------------------ .../SideDish/domain/DishDelivery.java | 31 --------------- .../sidedish/SideDish/domain/DishImage.java | 30 --------------- .../sidedish/SideDish/domain/DishSale.java | 32 ---------------- .../sidedish/SideDish/domain/Image.java | 12 ------ .../SideDish/domain/ImageRepository.java | 9 ++++- .../sidedish/SideDish/domain/Sale.java | 10 +---- .../sidedish/SideDish/dto/DishDetailDto.java | 10 +++-- .../sidedish/SideDish/dto/DishDto.java | 8 ++-- .../SideDish/service/DishService.java | 12 ++++-- 12 files changed, 27 insertions(+), 176 deletions(-) delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java delete mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 1044d5af13f6643d8aba4a106257317cfd19e7cd..a98306b6f5ad16c446e179c02bf037e5e152ccf2 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~j!e0st|41Tp{s literal 17 VcmZSX+g@Tc(fO$n0~j#70RS;<1S0?d diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java index 023a79ba2..fa990fbb7 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java @@ -2,9 +2,6 @@ import org.springframework.data.annotation.Id; -import java.util.HashSet; -import java.util.Set; - public class Delivery { @Id @@ -12,12 +9,6 @@ public class Delivery { private String deliveryType; - private Set dishDeliveries = new HashSet<>(); - - protected Delivery() { - - } - public Delivery(String deliveryType) { this.deliveryType = deliveryType; } @@ -30,8 +21,4 @@ public String getDeliveryType() { return deliveryType; } - public Set getDishDeliveries() { - return dishDeliveries; - } - } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index 18489f97b..f8767c7f5 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -1,8 +1,6 @@ package com.codesquad.sidedish.SideDish.domain; import java.time.LocalDateTime; -import java.util.HashSet; -import java.util.Set; public class Dish { @@ -19,28 +17,6 @@ public class Dish { private final Integer quantity; private final LocalDateTime currentDateTime; -// private final Set sales = new HashSet<>(); -// private final Set deliveries = new HashSet<>(); -// private final Set images = new HashSet<>(); - -// public void addSale(Sale... sales) { -// for (Sale sale : sales) { -// this.sales.add(sale); -// } -// } -// -// public void addDelivery(Delivery... deliveries) { -// for (Delivery delivery : deliveries) { -// this.deliveries.add(delivery); -// } -// } -// -// public void addImage(Image... images) { -// for (Image image : images) { -// this.images.add(image); -// } -// } - public Dish(String detailHash, String image, String title, String description, Integer price, Integer salePrice, Integer point, String deliveryInfo, Integer deliveryFee, Long categoryId, Integer quantity, LocalDateTime currentDateTime) { this.detailHash = detailHash; this.image = image; @@ -104,18 +80,6 @@ public LocalDateTime getCurrentDateTime() { return currentDateTime; } - public Set getSales() { - return new HashSet<>(); - } - - public Set getDeliveries() { - return new HashSet<>(); - } - - public Set getImages() { - return new HashSet<>(); - } - public boolean refreshable(long lastUpdated) { return false; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java deleted file mode 100644 index a26e828b5..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDelivery.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; - -public class DishDelivery { - - @Id - private Long id; - - private String dish; - - private Long delivery; - - @PersistenceConstructor - public DishDelivery(Long delivery) { - this.delivery = delivery; - } - - public Long getId() { - return id; - } - - public String getDish() { - return dish; - } - - public Long getDelivery() { - return delivery; - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java deleted file mode 100644 index 37004fbc7..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishImage.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; - -public class DishImage { - @Id - private Long id; - - private String dish; - - private Long image; - - @PersistenceConstructor - public DishImage(Long image) { - this.image = image; - } - - public Long getId() { - return id; - } - - public String getDish() { - return dish; - } - - public Long getImage() { - return image; - } -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java deleted file mode 100644 index 5bac80c75..000000000 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishSale.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.codesquad.sidedish.SideDish.domain; - -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; - -public class DishSale { - - @Id - private Long id; - - private String dish; - - private Long sale; - - @PersistenceConstructor - public DishSale(Long sale) { - this.sale = sale; - } - - public Long getId() { - return id; - } - - public String getDish() { - return dish; - } - - public Long getSale() { - return sale; - } - -} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java index 2cc1e0718..51978a69c 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java @@ -2,9 +2,6 @@ import org.springframework.data.annotation.Id; -import java.util.HashSet; -import java.util.Set; - public class Image { @Id @@ -14,11 +11,6 @@ public class Image { private String type; - private Set dishImages = new HashSet<>(); - - protected Image() { - } - public Image(String imageUrl, String type) { this.imageUrl = imageUrl; this.type = type; @@ -37,8 +29,4 @@ public String getType() { return type; } - public Set getDishImages() { - return dishImages; - } - } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java index 0e18e4f2b..69d2a5e60 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/ImageRepository.java @@ -1,7 +1,14 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface ImageRepository extends CrudRepository { -// List findAllByDishDetailHash(String dishDetailHash); + @Query("SELECT image.* from sidedish.image INNER JOIN sidedish.dish_image ON image.id = dish_image.image WHERE image.type = 'thumb' AND dish_image.dish = :detailHash;") + List findThumbImagesByDish(String detailHash); + + @Query("SELECT image.* from sidedish.image INNER JOIN sidedish.dish_image ON image.id = dish_image.image WHERE image.type = 'detail' AND dish_image.dish = :detailHash;") + List findDetailImagesByDish(String detailHash); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java index e12708041..c65893301 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java @@ -2,9 +2,6 @@ import org.springframework.data.annotation.Id; -import java.util.HashSet; -import java.util.Set; - public class Sale { @Id @@ -14,8 +11,6 @@ public class Sale { private String saleType; private int saleValue; - private Set dishSales = new HashSet<>(); - public Sale(String badge, String saleType, int saleValue) { this.badge = badge; @@ -38,9 +33,6 @@ public String getSaleType() { public int getSaleValue() { return saleValue; } - - public Set getDishSales() { - return dishSales; - } + } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java index aacc40a42..688ae6d25 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDetailDto.java @@ -21,16 +21,20 @@ private DishDetailDto(Builder builder) { this.detailImages = builder.detailImages; } - public static DishDetailDto from(Dish dish) { + public static DishDetailDto from(Dish dish, List thumbImages, List detailImages) { return new Builder() - .thumbImages(dish.getImages().stream().map(Image::getImageUrl).collect(Collectors.toList())) // TODO: + .thumbImages(imagesToUrls(thumbImages)) .point(dish.getPoint()) .deliveryInfo(dish.getDeliveryInfo()) .deliveryFee(dish.getDeliveryFee()) - .detailImages(dish.getImages().stream().map(Image::getImageUrl).collect(Collectors.toList())) // TODO: + .detailImages(imagesToUrls(detailImages)) .build(); } + private static List imagesToUrls(List images) { + return images.stream().map(Image::getImageUrl).collect(Collectors.toList()); + } + private static class Builder { private List thumbImages; private Integer point; diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java index 1cf5823de..be012b5ab 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java @@ -1,12 +1,10 @@ package com.codesquad.sidedish.SideDish.dto; -import com.codesquad.sidedish.SideDish.domain.Delivery; import com.codesquad.sidedish.SideDish.domain.Dish; -import com.codesquad.sidedish.SideDish.domain.Sale; +import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; public class DishDto { private final String detailHash; @@ -35,10 +33,10 @@ public static DishDto from(Dish dish) { .image(dish.getImage()) .title(dish.getTitle()) .description(dish.getDescription()) - .deliveryTypes(dish.getDeliveries().stream().map(Delivery::getDeliveryType).collect(Collectors.toList())) + .deliveryTypes(Arrays.asList("", "")) // TODO: .price(dish.getPrice()) .salePrice(dish.getSalePrice()) - .badges(dish.getSales().stream().map(Sale::getBadge).collect(Collectors.toList())) + .badges(Arrays.asList("", "")) // TODO: .build(); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 3d0206492..c145fdcb0 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -2,6 +2,8 @@ import com.codesquad.sidedish.SideDish.domain.Dish; import com.codesquad.sidedish.SideDish.domain.DishRepository; +import com.codesquad.sidedish.SideDish.domain.Image; +import com.codesquad.sidedish.SideDish.domain.ImageRepository; import com.codesquad.sidedish.SideDish.dto.DishDetailDto; import com.codesquad.sidedish.SideDish.dto.DishDto; import com.codesquad.sidedish.SideDish.dto.QuantityDto; @@ -16,9 +18,11 @@ @Service public class DishService { private final DishRepository dishRepository; + private final ImageRepository imageRepository; - public DishService(DishRepository dishRepository) { + public DishService(DishRepository dishRepository, ImageRepository imageRepository) { this.dishRepository = dishRepository; + this.imageRepository = imageRepository; } public List getList(Long categoryId) { @@ -41,9 +45,9 @@ public QuantityDto getDetailQuantity(String detailHash) { // public DishDetailDto getDetail(String detailHash) { Dish dish = dishRepository.findByDetailHash(detailHash); -// List tumb = imageRepository.findImagesByType("thum"); -// List detail = imageRepository.findImagesByType("detail"); - return DishDetailDto.from(dish); + List thumbImages = imageRepository.findThumbImagesByDish(detailHash); + List detailImages = imageRepository.findDetailImagesByDish(detailHash); + return DishDetailDto.from(dish, thumbImages, detailImages); } // From f3d5fb33fccf26534cb73bd5f954bebf9f91ebdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Thu, 29 Apr 2021 23:48:56 +0900 Subject: [PATCH 14/18] =?UTF-8?q?feat:=20dish=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=EC=84=9C=20delivery=20=ED=83=80=EC=9E=85=EA=B3=BC,=20?= =?UTF-8?q?badges=20=EA=B0=80=20=EB=82=98=EC=98=A4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../SideDish/domain/DeliveryRepository.java | 6 ++++- .../SideDish/domain/SaleRepository.java | 6 ++++- .../sidedish/SideDish/dto/DishDto.java | 10 +++++--- .../SideDish/service/DishService.java | 23 ++++++++++++------ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index a98306b6f5ad16c446e179c02bf037e5e152ccf2..5029ddc054dc93932017bdae7c4293db3f48b915 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~jzz0RS<81UCQx literal 17 VcmZSX+g@Tc(fO$n0~j!e0st|41Tp{s diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java index a258a21fc..b30d0e936 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DeliveryRepository.java @@ -1,7 +1,11 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface DeliveryRepository extends CrudRepository { -// List findAllByDishDetailHash(String dishDetailHash); + @Query("SELECT delivery.* from sidedish.delivery INNER JOIN sidedish.dish_delivery ON delivery.id = dish_delivery.delivery WHERE dish_delivery.dish = :detailHash;") + List findAllByDish(String detailHash); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java index 478ca4811..f14aedd18 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/SaleRepository.java @@ -1,7 +1,11 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface SaleRepository extends CrudRepository { -// List findAllByDishDetailHash(String dishDetailHash); + @Query("SELECT sale.* from sidedish.sale INNER JOIN sidedish.dish_sale ON sale.id = dish_sale.sale WHERE dish_sale.dish = :detailHash;") + List findAllByDish(String detailHash); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java index be012b5ab..94a0893d1 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java @@ -1,10 +1,12 @@ package com.codesquad.sidedish.SideDish.dto; +import com.codesquad.sidedish.SideDish.domain.Delivery; import com.codesquad.sidedish.SideDish.domain.Dish; +import com.codesquad.sidedish.SideDish.domain.Sale; -import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class DishDto { private final String detailHash; @@ -27,16 +29,16 @@ private DishDto(Builder builder) { this.badges = builder.badges; } - public static DishDto from(Dish dish) { + public static DishDto from(Dish dish, List deliveries, List sales) { return new Builder() .detailHash(dish.getDetailHash()) .image(dish.getImage()) .title(dish.getTitle()) .description(dish.getDescription()) - .deliveryTypes(Arrays.asList("", "")) // TODO: + .deliveryTypes(deliveries.stream().map(Delivery::getDeliveryType).collect(Collectors.toList())) .price(dish.getPrice()) .salePrice(dish.getSalePrice()) - .badges(Arrays.asList("", "")) // TODO: + .badges(sales.stream().map(Sale::getBadge).collect(Collectors.toList())) .build(); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index c145fdcb0..72198b68b 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -1,9 +1,6 @@ package com.codesquad.sidedish.SideDish.service; -import com.codesquad.sidedish.SideDish.domain.Dish; -import com.codesquad.sidedish.SideDish.domain.DishRepository; -import com.codesquad.sidedish.SideDish.domain.Image; -import com.codesquad.sidedish.SideDish.domain.ImageRepository; +import com.codesquad.sidedish.SideDish.domain.*; import com.codesquad.sidedish.SideDish.dto.DishDetailDto; import com.codesquad.sidedish.SideDish.dto.DishDto; import com.codesquad.sidedish.SideDish.dto.QuantityDto; @@ -19,18 +16,30 @@ public class DishService { private final DishRepository dishRepository; private final ImageRepository imageRepository; + private final DeliveryRepository deliveryRepository; + private final SaleRepository saleRepository; - public DishService(DishRepository dishRepository, ImageRepository imageRepository) { + public DishService(DishRepository dishRepository, ImageRepository imageRepository, DeliveryRepository deliveryRepository, SaleRepository saleRepository) { this.dishRepository = dishRepository; this.imageRepository = imageRepository; + this.deliveryRepository = deliveryRepository; + this.saleRepository = saleRepository; } public List getList(Long categoryId) { return dishRepository.findAllByCategoryId(categoryId) - .stream().map(DishDto::from) + .stream().map(this::convert) .collect(Collectors.toList()); } + // FIXME: N+1 문제를 해결해야한다. + private DishDto convert(Dish dish) { + String detailHash = dish.getDetailHash(); + List deliveries = deliveryRepository.findAllByDish(detailHash); + List sales = saleRepository.findAllByDish(detailHash); + return DishDto.from(dish, deliveries, sales); + } + public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { Dish dish = dishRepository.findByDetailHash(detailHash); @@ -42,14 +51,12 @@ public QuantityDto getDetailQuantity(String detailHash) { return QuantityDto.from(getDish(detailHash)); } - // public DishDetailDto getDetail(String detailHash) { Dish dish = dishRepository.findByDetailHash(detailHash); List thumbImages = imageRepository.findThumbImagesByDish(detailHash); List detailImages = imageRepository.findDetailImagesByDish(detailHash); return DishDetailDto.from(dish, thumbImages, detailImages); } -// private Dish getDish(String detailHash) { Dish dish = dishRepository.findByDetailHash(detailHash); From 07e69c41e8eb22571f46bf6d8563947373005670 Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Fri, 30 Apr 2021 11:03:30 +0900 Subject: [PATCH 15/18] =?UTF-8?q?feat:=20=EC=A3=BC=EB=AC=B8=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 17 bytes backend/.gradle/checksums/checksums.lock | Bin 17 -> 17 bytes .../SideDish/controller/DishController.java | 15 +++++++++++---- .../codesquad/sidedish/SideDish/domain/Dish.java | 6 +++++- .../sidedish/SideDish/domain/DishRepository.java | 5 +++++ .../sidedish/SideDish/service/DishService.java | 15 ++++++++++++++- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 5029ddc054dc93932017bdae7c4293db3f48b915..5c9de7101734f2995967ba105eef72fa9bba8e06 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~jzD0st|W1Wo_| literal 17 VcmZSX+g@Tc(fO$n0~jzz0RS<81UCQx diff --git a/backend/.gradle/checksums/checksums.lock b/backend/.gradle/checksums/checksums.lock index fd6d57e624fb7360a3290a15ee0355a1e35d3701..fa673f4e314c49b45076518b115b939ebbaa62c1 100644 GIT binary patch literal 17 UcmZQB-}L0L%>TQY3=qH!06`oDH~;_u literal 17 TcmZQB-}L0L%>TQY3{U_7K^X-# diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java index 23bef7545..43b69e621 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java @@ -7,10 +7,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -53,6 +50,15 @@ public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별 return ResponseEntity.ok().body(quantityDto); } + @PostMapping("/detail/{detailHash}/{count}") + @ApiOperation(value = "주문하기", notes = "주문하기") + public ResponseEntity orderDish(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @PathVariable("count") int count) { + if (dishService.order(detailHash, count)) { + return ResponseEntity.ok().body("주문완료"); + } + return ResponseEntity.ok().body("주문불가"); + } + @GetMapping("/main") @ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") public ResponseEntity> getMainList() { @@ -73,4 +79,5 @@ public ResponseEntity> getSideList() { List dishes = dishService.getList(3L); return ResponseEntity.ok().body(dishes); } + } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index f8767c7f5..26a3758ed 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -14,7 +14,7 @@ public class Dish { private final String deliveryInfo; private final Integer deliveryFee; private final Long categoryId; - private final Integer quantity; + private Integer quantity; private final LocalDateTime currentDateTime; public Dish(String detailHash, String image, String title, String description, Integer price, Integer salePrice, Integer point, String deliveryInfo, Integer deliveryFee, Long categoryId, Integer quantity, LocalDateTime currentDateTime) { @@ -32,6 +32,10 @@ public Dish(String detailHash, String image, String title, String description, I this.currentDateTime = currentDateTime; } + public void order(int count) { + this.quantity -= count; + } + public String getDetailHash() { return detailHash; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java index 18e8088ca..6625f54e1 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishRepository.java @@ -1,5 +1,6 @@ package com.codesquad.sidedish.SideDish.domain; +import org.springframework.data.jdbc.repository.query.Modifying; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; @@ -11,4 +12,8 @@ public interface DishRepository extends CrudRepository { @Query("SELECT * from sidedish.dish WHERE dish.detail_hash = :detailHash") Dish findByDetailHash(String detailHash); + + @Modifying + @Query("UPDATE sidedish.dish SET dish.quantity = :quantity WHERE dish.detail_hash = :detailHash") + void updateDish(int quantity, String detailHash); } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 72198b68b..7a62bc9a5 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -33,7 +33,7 @@ public List getList(Long categoryId) { } // FIXME: N+1 문제를 해결해야한다. - private DishDto convert(Dish dish) { + DishDto convert(Dish dish) { String detailHash = dish.getDetailHash(); List deliveries = deliveryRepository.findAllByDish(detailHash); List sales = saleRepository.findAllByDish(detailHash); @@ -63,4 +63,17 @@ private Dish getDish(String detailHash) { return Optional.ofNullable(dish) .orElseThrow(() -> new DishNotFoundException(detailHash)); } + + public boolean order(String detailHash, int count) { + Dish dish = getDish(detailHash); + QuantityDto quantityDto = getDetailQuantity(detailHash); + if (quantityDto.getQuantity() > count) { + int upqua = quantityDto.getQuantity() - count; + dish.order(count); + dishRepository.updateDish(upqua, detailHash); + return true; + } + return false; + } + } From 997048b690c06ee320d4d0306f7d176cc91e993b Mon Sep 17 00:00:00 2001 From: JoonKi-Kim Date: Fri, 30 Apr 2021 11:07:42 +0900 Subject: [PATCH 16/18] =?UTF-8?q?feat:=20post=20->=20patch=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codesquad/sidedish/SideDish/controller/DishController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java index 43b69e621..33e43a3e3 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/controller/DishController.java @@ -50,7 +50,7 @@ public ResponseEntity getDetailQuantity(@ApiParam("요리의 식별 return ResponseEntity.ok().body(quantityDto); } - @PostMapping("/detail/{detailHash}/{count}") + @PatchMapping("/detail/{detailHash}/{count}") @ApiOperation(value = "주문하기", notes = "주문하기") public ResponseEntity orderDish(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @PathVariable("count") int count) { if (dishService.order(detailHash, count)) { From 84529835c16d4b138b3c3e3b9f4dfd766366d98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Fri, 30 Apr 2021 12:35:25 +0900 Subject: [PATCH 17/18] =?UTF-8?q?feat:=20JDBC=20Template=20=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20N=20+=201=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidedish/SideDish/domain/Delivery.java | 27 +++++--- .../sidedish/SideDish/domain/Dish.java | 19 +++++- .../sidedish/SideDish/domain/DishDao.java | 64 +++++++++++++++++++ .../sidedish/SideDish/domain/DishList.java | 37 +++++++++++ .../sidedish/SideDish/domain/Image.java | 11 ---- .../sidedish/SideDish/domain/Sale.java | 27 +++++--- .../SideDish/service/DishService.java | 26 +++++--- 7 files changed, 170 insertions(+), 41 deletions(-) create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDao.java create mode 100644 backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishList.java diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java index fa990fbb7..733298492 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Delivery.java @@ -1,24 +1,33 @@ package com.codesquad.sidedish.SideDish.domain; -import org.springframework.data.annotation.Id; +import java.util.Objects; public class Delivery { - - @Id - private Long id; - private String deliveryType; public Delivery(String deliveryType) { this.deliveryType = deliveryType; } - public Long getId() { - return id; - } - public String getDeliveryType() { return deliveryType; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Delivery delivery = (Delivery) o; + return Objects.equals(deliveryType, delivery.deliveryType); + } + + @Override + public int hashCode() { + return Objects.hash(deliveryType); + } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java index 26a3758ed..746adf22f 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Dish.java @@ -1,9 +1,9 @@ package com.codesquad.sidedish.SideDish.domain; import java.time.LocalDateTime; +import java.util.Objects; public class Dish { - private final String detailHash; private final String image; private final String title; @@ -87,4 +87,21 @@ public LocalDateTime getCurrentDateTime() { public boolean refreshable(long lastUpdated) { return false; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dish dish = (Dish) o; + return Objects.equals(detailHash, dish.detailHash) && Objects.equals(image, dish.image) && Objects.equals(title, dish.title) && Objects.equals(description, dish.description) && Objects.equals(price, dish.price) && Objects.equals(salePrice, dish.salePrice) && Objects.equals(point, dish.point) && Objects.equals(deliveryInfo, dish.deliveryInfo) && Objects.equals(deliveryFee, dish.deliveryFee) && Objects.equals(categoryId, dish.categoryId) && Objects.equals(quantity, dish.quantity) && Objects.equals(currentDateTime, dish.currentDateTime); + } + + @Override + public int hashCode() { + return Objects.hash(detailHash, image, title, description, price, salePrice, point, deliveryInfo, deliveryFee, categoryId, quantity, currentDateTime); + } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDao.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDao.java new file mode 100644 index 000000000..a74828433 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishDao.java @@ -0,0 +1,64 @@ +package com.codesquad.sidedish.SideDish.domain; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.stereotype.Repository; + +import javax.sql.DataSource; +import java.sql.Timestamp; +import java.util.Date; +import java.util.Optional; + +@Repository +public class DishDao { + private Logger logger = LoggerFactory.getLogger(DishDao.class); + + private JdbcTemplate jdbcTemplate; + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + @Autowired + public DishDao(DataSource dataSource) { + jdbcTemplate = new JdbcTemplate(dataSource); + namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); + } + + + public DishList findAllByCategoryId(Long categoryId) { + String sql = "SELECT dish.*, delivery.delivery_type, sale.badge, sale.sale_type, sale.sale_value from sidedish.dish" + + " LEFT OUTER JOIN sidedish.dish_delivery ON dish.detail_hash = dish_delivery.dish" + + " LEFT OUTER JOIN sidedish.delivery ON delivery.id = dish_delivery.delivery" + + " LEFT OUTER JOIN sidedish.dish_sale ON dish.detail_hash = dish_sale.dish" + + " LEFT OUTER JOIN sidedish.sale ON sale.id = dish_sale.sale" + + " WHERE dish.category_id = " + categoryId; + + DishList dishList = new DishList(); + jdbcTemplate.query(sql, (rs, rowNum) -> { + Dish dish = new Dish( + rs.getString("detail_hash"), + rs.getString("image"), + rs.getString("title"), + rs.getString("description"), + rs.getInt("price"), + rs.getInt("sale_price"), + rs.getInt("point"), + rs.getString("delivery_info"), + rs.getInt("delivery_fee"), + rs.getLong("category_id"), + rs.getInt("quantity"), + Optional.ofNullable(rs.getTimestamp("current_date_time")).orElse(new Timestamp(new Date().getTime())).toLocalDateTime() + ); + + Delivery delivery = new Delivery(rs.getString("delivery_type")); + Sale sale = new Sale(rs.getString("badge"), + rs.getString("sale_type"), + rs.getInt("sale_value")); + dishList.addDish(dish, delivery, sale); + + return null; + }); + return dishList; + } +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishList.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishList.java new file mode 100644 index 000000000..b05641d50 --- /dev/null +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/DishList.java @@ -0,0 +1,37 @@ +package com.codesquad.sidedish.SideDish.domain; + +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +public class DishList { + private final Set dishes = new LinkedHashSet<>(); + private final Map> deliveriesMap = new HashMap<>(); + private final Map> salesMap = new HashMap<>(); + + public void addDish(Dish dish, Delivery delivery, Sale sale) { + dishes.add(dish); + + Set deliveries = getDeliveries(dish); + Set sales = getSales(dish); + + deliveries.add(delivery); + sales.add(sale); + + deliveriesMap.put(dish, deliveries); + salesMap.put(dish, sales); + } + + public Set getDishes() { + return dishes; + } + + public Set getDeliveries(Dish dish) { + return deliveriesMap.getOrDefault(dish, new LinkedHashSet<>()); + } + + public Set getSales(Dish dish) { + return salesMap.getOrDefault(dish, new LinkedHashSet<>()); + } +} diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java index 51978a69c..beb8a7a1f 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Image.java @@ -1,12 +1,6 @@ package com.codesquad.sidedish.SideDish.domain; -import org.springframework.data.annotation.Id; - public class Image { - - @Id - private Long id; - private String imageUrl; private String type; @@ -16,11 +10,6 @@ public Image(String imageUrl, String type) { this.type = type; } - - public Long getId() { - return id; - } - public String getImageUrl() { return imageUrl; } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java index c65893301..9e382c23d 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/domain/Sale.java @@ -1,12 +1,8 @@ package com.codesquad.sidedish.SideDish.domain; -import org.springframework.data.annotation.Id; +import java.util.Objects; public class Sale { - - @Id - private Long id; - private String badge; private String saleType; private int saleValue; @@ -18,10 +14,6 @@ public Sale(String badge, String saleType, int saleValue) { this.saleValue = saleValue; } - public Long getId() { - return id; - } - public String getBadge() { return badge; } @@ -33,6 +25,21 @@ public String getSaleType() { public int getSaleValue() { return saleValue; } - + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Sale sale = (Sale) o; + return saleValue == sale.saleValue && Objects.equals(badge, sale.badge) && Objects.equals(saleType, sale.saleType); + } + + @Override + public int hashCode() { + return Objects.hash(badge, saleType, saleValue); + } } diff --git a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java index 7a62bc9a5..3366e5bf2 100644 --- a/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java +++ b/backend/src/main/java/com/codesquad/sidedish/SideDish/service/DishService.java @@ -8,6 +8,7 @@ import com.codesquad.sidedish.SideDish.exception.DishNotFoundException; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -18,27 +19,32 @@ public class DishService { private final ImageRepository imageRepository; private final DeliveryRepository deliveryRepository; private final SaleRepository saleRepository; + private final DishDao dishDao; - public DishService(DishRepository dishRepository, ImageRepository imageRepository, DeliveryRepository deliveryRepository, SaleRepository saleRepository) { + public DishService(DishRepository dishRepository, ImageRepository imageRepository, DeliveryRepository deliveryRepository, SaleRepository saleRepository, DishDao dishDao) { this.dishRepository = dishRepository; this.imageRepository = imageRepository; this.deliveryRepository = deliveryRepository; this.saleRepository = saleRepository; + this.dishDao = dishDao; } public List getList(Long categoryId) { - return dishRepository.findAllByCategoryId(categoryId) - .stream().map(this::convert) + DishList dishList = dishDao.findAllByCategoryId(categoryId); + return dishList.getDishes().stream() + .map(dish -> DishDto.from(dish, new ArrayList<>(dishList.getDeliveries(dish)), new ArrayList<>(dishList.getSales(dish)))) .collect(Collectors.toList()); +// return dishRepository.findAllByCategoryId(categoryId) +// .stream().map(this::convert) +// .collect(Collectors.toList()); } - // FIXME: N+1 문제를 해결해야한다. - DishDto convert(Dish dish) { - String detailHash = dish.getDetailHash(); - List deliveries = deliveryRepository.findAllByDish(detailHash); - List sales = saleRepository.findAllByDish(detailHash); - return DishDto.from(dish, deliveries, sales); - } +// private DishDto convert(Dish dish) { +// String detailHash = dish.getDetailHash(); +// List deliveries = deliveryRepository.findAllByDish(detailHash); +// List sales = saleRepository.findAllByDish(detailHash); +// return DishDto.from(dish, deliveries, sales); +// } public RefreshDto getDetailRefreshable(String detailHash, long lastUpdated) { From 4db83709b0ef060d0e12a80b9f15d32f63c7b56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=A9=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B?= =?UTF-8?q?=E1=85=AA=E1=86=AB=20=28Can=29?= Date: Sun, 2 May 2021 13:00:16 +0900 Subject: [PATCH 18/18] =?UTF-8?q?feat:=20pstm=20=EC=9C=BC=EB=A1=9C=20SQL?= =?UTF-8?q?=20Injection=20=ED=95=B4=ED=82=B9=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 17 bytes .../sidedish/SideDish/domain/DishDao.java | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/backend/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 5c9de7101734f2995967ba105eef72fa9bba8e06..406a8407223f1829390664c263924415cfd215c9 100644 GIT binary patch literal 17 VcmZSX+g@Tc(fO$n0~j!u0RS { + ps.setLong(1, categoryId); + }; DishList dishList = new DishList(); - jdbcTemplate.query(sql, (rs, rowNum) -> { + jdbcTemplate.query(sql, pstmSetter,(rs, rowNum) -> { Dish dish = new Dish( rs.getString("detail_hash"), rs.getString("image"),