From b58f0c9707c322ec64774a2ac0a135ee2383a654 Mon Sep 17 00:00:00 2001 From: orieasy1 Date: Sun, 24 Nov 2024 05:57:30 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20db=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/easy/store/service/ImageService.java | 4 +- src/main/resources/application.yml | 2 +- src/main/resources/data.sql | 76 +++++++------------ 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/jojoidu/book/easy/store/service/ImageService.java b/src/main/java/com/jojoidu/book/easy/store/service/ImageService.java index 4ff023f..bdeac11 100644 --- a/src/main/java/com/jojoidu/book/easy/store/service/ImageService.java +++ b/src/main/java/com/jojoidu/book/easy/store/service/ImageService.java @@ -16,6 +16,8 @@ import java.util.UUID; +import static org.apache.commons.io.FilenameUtils.getExtension; + @RequiredArgsConstructor @Transactional @Service @@ -51,7 +53,7 @@ public OptionImageResponse uploadOptionImage(Long menuId, Long optionId, Multipa throw new MenuException(MenuErrorCode.INVALID_OPTION_FOR_MENU); } - String fileName = UUID.randomUUID() + imageFile.getOriginalFilename(); + String fileName = "menu_" + menuId + "_" + getExtension(imageFile.getOriginalFilename()); // 파일데이터와 파일명 넘겨서 S3에 저장 String imageUrl = s3Service.uploadFile(imageFile, fileName); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a15f209..f478e12 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: dev + active: prod springdoc: packages-to-scan: com.jojoidu.book.easy default-consumes-media-type: application/json;charset=UTF-8 diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 1710920..cc04f28 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -51,55 +51,33 @@ VALUES ('FOOD', '후렌치후라이', '감자튀김',NOW(),NOW()); -- 메뉴 삽입 -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (1, 1, '시즌메뉴', '방어 사시미', 40000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (2, 1, '시즌메뉴', '굴탕면', 21000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (3, 1, '시즌메뉴', '고구마맛탕', 12000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (4, 1, '런치세트', '초밥 정식', 12000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (5, 1, '런치세트', '우동 정식', 11000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (6, 1, '메인', '모듬꼬치', 18000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (7, 1, '메인', '짬뽕탕 (면 포함)', 16000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (8, 1, '사이드', '닭튀김', 8000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (9, 2, '커피', '아메리카노', 1700); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (10, 2, '커피', '콜드브루', 2800); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (11, 2, '논커피', '아이스티', 2100); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (12, 2, '디저트', '소금빵', 5100); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (13, 2, '디저트', '크림치즈베이글', 6000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (14, 2, '시즌메뉴', '딸기주스', 6000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (15, 2, '시즌메뉴', '딸기라떼', 7000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (16, 2, '시즌메뉴', '꿀밤라떼', 7500); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (17, 3, '햄버거', '비프치즈버거', 6500); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (18, 3, '햄버거', '치킨마일드버거', 7200); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (19, 3, '햄버거', '핫포크버거', 6000); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (20, 3, '사이드', '감자튀김', 1500); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (21, 3, '사이드', '치즈스틱', 1500); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (22, 3, '사이드', '스윗소스', 300); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (23, 3, '음료', '콜라', 1500); -INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) -VALUES (24, 3, '사이드', '사이다', 1500);INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price) - VALUES (25, 3, '디저트', '아이스크림', 1200); +INSERT INTO menu (menu_id, store_id, category, menu_name, menu_price, image_url) +VALUES + (1, 1, '시즌메뉴', '방어 사시미', 40000, NULL), + (2, 1, '시즌메뉴', '굴탕면', 21000, NULL), + (3, 1, '시즌메뉴', '고구마맛탕', 12000, NULL), + (4, 1, '런치세트', '초밥 정식', 12000, NULL), + (5, 1, '런치세트', '우동 정식', 11000, NULL), + (6, 1, '메인', '모듬꼬치', 18000, NULL), + (7, 1, '메인', '짬뽕탕 (면 포함)', 16000, NULL), + (8, 1, '사이드', '닭튀김', 8000, NULL), + (9, 2, '커피', '아메리카노', 1700, NULL), + (10, 2, '커피', '콜드브루', 2800, NULL), + (11, 2, '논커피', '아이스티', 2100, NULL), + (12, 2, '디저트', '소금빵', 5100, NULL), + (13, 2, '디저트', '크림치즈베이글', 6000, NULL), + (14, 2, '시즌메뉴', '딸기주스', 6000, NULL), + (15, 2, '시즌메뉴', '딸기라떼', 7000, NULL), + (16, 2, '시즌메뉴', '꿀밤라떼', 7500, NULL), + (17, 3, '햄버거', '비프치즈버거', 6500, NULL), + (18, 3, '햄버거', '치킨마일드버거', 7200, NULL), + (19, 3, '햄버거', '핫포크버거', 6000, NULL), + (20, 3, '사이드', '감자튀김', 1500, NULL), + (21, 3, '사이드', '치즈스틱', 1500, NULL), + (22, 3, '사이드', '스윗소스', 300, NULL), + (23, 3, '음료', '콜라', 1500), + (24, 3, '사이드', '사이다', 1500), + (25, 3, '디저트', '아이스크림', 1200); -- 메뉴 ID가 2이라고 가정 (menu_id = 2)