From f75dc0abae588a56948ef527a3b03e2b7d7158dc Mon Sep 17 00:00:00 2001 From: hawardShin Date: Sun, 24 Nov 2024 00:20:39 +0900 Subject: [PATCH 1/7] Feat: Set data.sql --- src/main/resources/data.sql | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 8675680..deae302 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -4,4 +4,48 @@ INSERT INTO store (id, store_name) VALUES (3, '패스트푸드'); INSERT INTO video (store_id, video_url) VALUES (2, 'https://youtu.be/-_FS661Q1nw'); -INSERT INTO video (store_id, video_url) VALUES (3, 'https://youtu.be/i6tRr8r-2l0'); \ No newline at end of file +INSERT INTO video (store_id, video_url) VALUES (3, 'https://youtu.be/i6tRr8r-2l0'); + + +INSERT INTO word (type, word, description,created_at, updated_at) +VALUES + ('CAFE', '디카페인', '카페인을 뺀 것',NOW(),NOW()), + ('CAFE', '라떼', '우유가 섞인 커피 (달달하게 요청 가능)',NOW(),NOW()), + ('CAFE', '마키아토', '에스프레소에 우유 거품을 얹은 커피 (조금 달달한 편)',NOW(),NOW()), + ('CAFE', '버블티', '쫀득한 펄이 들어있는 밀크티',NOW(),NOW()), + ('CAFE', '베버리지', '모든 종류의 음료를 지칭, 주로 커피 외 달달한 음료를 지칭함',NOW(),NOW()), + ('CAFE', '베이커리', '빵류',NOW(),NOW()), + ('CAFE', '블렌딩 티', '여러 종류 찻잎을 섞어 만든 차 (메뉴에 따라 달 수 있음)',NOW(),NOW()), + ('CAFE', '샷 추가', '커피를 더 진하게 하도록 추가하는 것',NOW(),NOW()), + ('CAFE', '스파클링티', '탄산이 들어간 음료',NOW(),NOW()), + ('CAFE', '아포가토', '아이스크림에 에스프레소를 부은 디저트',NOW(),NOW()), + ('CAFE', '에스프레소', '소주 한 잔 정도로 작고 진하게 내린 커피',NOW(),NOW()), + ('CAFE', '에이드', '과일청과 탄산수를 섞어 만든 음료',NOW(),NOW()), + ('CAFE', '제로 슈거', '혈당에 영향을 주지 않는 당류, 혹은 저당',NOW(),NOW()), + ('CAFE', '콜드브루', '찬물로 오랜 시간 우려낸 커피',NOW(),NOW()), + ('CAFE', '테이크아웃', '매장 밖으로 포장하는 것',NOW(),NOW()), + ('CAFE', '티', '단 맛이 적은 차',NOW(),NOW()), + ('CAFE', '프라푸치노', '얼음을 갈아만든 음료',NOW(),NOW()), + ('CAFE', '프룻 / 프루트', '과일',NOW(),NOW()), + ('CAFE', '플랫치노', '얼음을 갈아만든 음료',NOW(),NOW()), + ('FOOD', '디저트', '후식식',NOW(),NOW()), + ('FOOD', '리미티드', '한정 수량 메뉴',NOW(),NOW()), + ('FOOD', '바우처', '결제에 사용할 수 있는 할인권',NOW(),NOW()), + ('FOOD', '베스트', '해당 식당에서 제일 잘 나가는 메뉴',NOW(),NOW()), + ('FOOD', '사이드', '주 메뉴에 곁들여 먹는 음식',NOW(),NOW()), + ('FOOD', '샷', '술 한 잔',NOW(),NOW()), + ('FOOD', '셀프바', '스스로 음식을 가져갈 수 있는 장소',NOW(),NOW()), + ('FOOD', '스캔', '바코드를 읽는 것',NOW(),NOW()), + ('FOOD', '슬롯', '카드를 넣는 구멍',NOW(),NOW()), + ('FOOD', '시그니처', '해당 식당의 대표 메뉴',NOW(),NOW()), + ('FOOD', '오더', '주문',NOW(),NOW()), + ('FOOD', '이벤트', '할인이나 증정 등 특별 행사',NOW(),NOW()), + ('FOOD', '커스텀', '기호에 맞춰서 선택',NOW(),NOW()), + ('FOOD', '테이블번호', '내가 앉은 자리의 번호',NOW(),NOW()), + ('FOOD', '토핑', '음식 위에 추가로 얹는 재료',NOW(),NOW()), + ('FOOD', '트레이', '쟁반',NOW(),NOW()), + ('FOOD', '페이', '결제하기, 주로 간편 결제 수단을 뜻하는 용어',NOW(),NOW()), + ('FOOD', '프로모션', '할인이나 증정 등 특별 행사',NOW(),NOW()), + ('FOOD', '피크타임', '사람이 가장 붐비는 시간대',NOW(),NOW()), + ('FOOD', '픽업', '주문한 음식을 찾아가는 것',NOW(),NOW()), + ('FOOD', '후렌치후라이', '감자튀김',NOW(),NOW()); \ No newline at end of file From 88e12eedaccc05942d2432862fae2a4ea9678731 Mon Sep 17 00:00:00 2001 From: hawardShin Date: Sun, 24 Nov 2024 00:37:22 +0900 Subject: [PATCH 2/7] Feat: Search word --- .../easy/dictionary/repository/WordRepository.java | 14 +++++++++++--- .../easy/dictionary/service/DictionaryService.java | 8 ++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java b/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java index b3d0005..93f29be 100644 --- a/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java +++ b/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java @@ -4,6 +4,8 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.jojoidu.book.easy.dictionary.entity.Word; import com.jojoidu.book.easy.dictionary.entity.WordType; @@ -17,8 +19,14 @@ public interface WordRepository extends JpaRepository{ List findByWordContainingOrDescriptionContaining(String wordKeyword, String descriptionKeyword); // 타입과 키워드로 검색 - List findByTypeAndWordContainingOrTypeAndDescriptionContaining( - WordType type1, String wordKeyword1, - WordType type2, String descriptionKeyword2 + @Query(""" + SELECT w + FROM Word w + WHERE w.type = :type + AND (w.word LIKE %:keyword% OR w.description LIKE %:keyword%) +""") + List findByTypeAndKeywordInWordOrDescription( + @Param("type") WordType type, + @Param("keyword") String keyword ); } diff --git a/src/main/java/com/jojoidu/book/easy/dictionary/service/DictionaryService.java b/src/main/java/com/jojoidu/book/easy/dictionary/service/DictionaryService.java index ec78e16..3c02c3c 100644 --- a/src/main/java/com/jojoidu/book/easy/dictionary/service/DictionaryService.java +++ b/src/main/java/com/jojoidu/book/easy/dictionary/service/DictionaryService.java @@ -22,13 +22,9 @@ public WordTypeResDto getDictionary(WordReqType type, String keyword) { if (type == WordReqType.ALL) { dto.setByWords(wordRepository.findByWordContainingOrDescriptionContaining(keyword, keyword)); } else { - dto.setByWords(wordRepository.findByType(WordType.from(type))); - dto.setByWords(wordRepository.findByTypeAndWordContainingOrTypeAndDescriptionContaining( - WordType.from(type), keyword, - WordType.from(type), keyword - )); + dto.setByWords(wordRepository.findByTypeAndKeywordInWordOrDescription( + WordType.from(type), keyword)); } return dto; } - } From c8e0f655179b856e61c9cd78f61020dd4ae9e9aa Mon Sep 17 00:00:00 2001 From: hawardShin Date: Sun, 24 Nov 2024 00:39:29 +0900 Subject: [PATCH 3/7] Feat: Delete not use method --- .../book/easy/dictionary/repository/WordRepository.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java b/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java index 93f29be..999ee8b 100644 --- a/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java +++ b/src/main/java/com/jojoidu/book/easy/dictionary/repository/WordRepository.java @@ -11,10 +11,6 @@ import com.jojoidu.book.easy.dictionary.entity.WordType; public interface WordRepository extends JpaRepository{ - - List findByType(WordType type); - - // 전체 검색 (ALL) List findByWordContainingOrDescriptionContaining(String wordKeyword, String descriptionKeyword); From 118e0d888d3673bc24a4f49374d115cdb7a581c6 Mon Sep 17 00:00:00 2001 From: hawardShin Date: Sun, 24 Nov 2024 01:00:33 +0900 Subject: [PATCH 4/7] Feat: Set CI/CD --- .github/workflows/CICD.yml | 55 ++++++++++++++++++++++++++++++++++++++ scripts/start.sh | 21 +++++++++++++++ scripts/stop.sh | 19 +++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 .github/workflows/CICD.yml create mode 100644 scripts/start.sh create mode 100644 scripts/stop.sh diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml new file mode 100644 index 0000000..e590efe --- /dev/null +++ b/.github/workflows/CICD.yml @@ -0,0 +1,55 @@ +# 1 워크플로의 이름 지정 +name: CI and Deploy to Amazon EC2 +# 2 워크플로가 시작될 조건 지정 +env: + AWS_REGION: ap-northeast-2 + S3_BUCKET_NAME: easy-deploy + CODE_DEPLOY_APPLICATION_NAME: easy-deploy + CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: easy-deploy-group +permissions: + contents: read +on: + push: + branches: [ main ] +jobs: + build: + runs-on: ubuntu-latest # 3 실행 환경 지정 + #4 실행스텝지정 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + # db.properties 파일 생성 + - name: Make application.properties + run: | + cd ./src/main/resources + echo "${{ secrets.SECRET_PROPERTIES }}" > ./application-prod.yml + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew clean build + # (4) AWS 인증 (IAM 사용자 Access Key, Secret Key 활용) + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + # (5) 빌드 결과물을 S3 버킷에 업로드 + - name: Upload to AWS S3 + run: | + aws deploy push \ + --application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ + --s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ + --source . + # (6) S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행 + - name: Deploy to AWS EC2 from S3 + run: | + aws deploy create-deployment \ + --application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ + --deployment-config-name CodeDeployDefault.AllAtOnce \ + --deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ + --s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100644 index 0000000..126f2cb --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +PROJECT_ROOT="/home/ubuntu" +JAR_FILE="$PROJECT_ROOT/easy-0.0.1-SNAPSHOT.jar" + +APP_LOG="$PROJECT_ROOT/application.log" +ERROR_LOG="$PROJECT_ROOT/error.log" +DEPLOY_LOG="$PROJECT_ROOT/deploy.log" + +TIME_NOW=$(date +%c) + +# build 파일 복사 +echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG +cp $PROJECT_ROOT/build/build/libs/billage-0.0.1-SNAPSHOT.jar $JAR_FILE + +# jar 파일 실행 +echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG +nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & + +CURRENT_PID=$(pgrep -f $JAR_FILE) +echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG diff --git a/scripts/stop.sh b/scripts/stop.sh new file mode 100644 index 0000000..02ecd84 --- /dev/null +++ b/scripts/stop.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +PROJECT_ROOT="/home/ubuntu" +JAR_FILE="easy-0.0.1-SNAPSHOT.jar" + +DEPLOY_LOG="$PROJECT_ROOT/deploy.log" + +TIME_NOW=$(date +%c) + +# 현재 구동 중인 애플리케이션 pid 확인 +CURRENT_PID=$(pgrep -f $JAR_FILE) + +# 프로세스가 켜져 있으면 종료 +if [ -z $CURRENT_PID ]; then + echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG +else + echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG + kill -15 $CURRENT_PID +fi From 300c14176367abac79731c8f8a13393e673b8aaa Mon Sep 17 00:00:00 2001 From: hawardShin Date: Sun, 24 Nov 2024 01:40:00 +0900 Subject: [PATCH 5/7] merge --- .../book/easy/global/config/S3Config.java | 36 +++++++++ .../store/controller/ImageController.java | 60 ++++++++++++++ .../store/controller/StoreController.java | 37 +++++++-- .../easy/store/dto/MenuDetailsResponse.java | 44 ++++++++++ .../easy/store/dto/MenuImageResponse.java | 19 +++++ .../book/easy/store/dto/MenuListResponse.java | 39 +++++++++ .../easy/store/dto/OptionImageResponse.java | 23 ++++++ .../book/easy/store/entity/menu/Menu.java | 18 ++--- .../book/easy/store/entity/menu/Option.java | 14 ++-- .../easy/store/exception/MenuErrorCode.java | 41 ++++++++++ .../easy/store/exception/MenuException.java | 9 +++ .../easy/store/exception/StoreErrorCode.java | 7 +- .../easy/store/repository/MenuRepository.java | 15 ++++ .../store/repository/OptionRepository.java | 10 +++ .../store/repository/StoreRepository.java | 2 + .../book/easy/store/service/ImageService.java | 63 +++++++++++++++ .../book/easy/store/service/S3Service.java | 31 +++++++ .../book/easy/store/service/StoreService.java | 81 +++++++++++++++++++ src/main/resources/data.sql | 59 +++++++++++++- 19 files changed, 580 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/jojoidu/book/easy/global/config/S3Config.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/controller/ImageController.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/dto/MenuDetailsResponse.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/dto/MenuImageResponse.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/dto/MenuListResponse.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/dto/OptionImageResponse.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/exception/MenuErrorCode.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/exception/MenuException.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/repository/MenuRepository.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/repository/OptionRepository.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/service/ImageService.java create mode 100644 src/main/java/com/jojoidu/book/easy/store/service/S3Service.java diff --git a/src/main/java/com/jojoidu/book/easy/global/config/S3Config.java b/src/main/java/com/jojoidu/book/easy/global/config/S3Config.java new file mode 100644 index 0000000..0aa6a35 --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/global/config/S3Config.java @@ -0,0 +1,36 @@ +package com.jojoidu.book.easy.global.config; + +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class S3Config { + @Value("${cloud.aws.credentials.accessKey}") + private String accessKey; + + @Value("${cloud.aws.credentials.secretKey}") + private String secretKey; + + @Value("${cloud.aws.s3.bucket-name}") + private String bucketName; + + @Value("${cloud.aws.region.static}") + private String region; + + @Bean + public AmazonS3Client s3Builder() { + AWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey); + System.setProperty("com.amazonaws.sdk.disableCertChecking", "true"); + + return (AmazonS3Client) AmazonS3ClientBuilder.standard() + .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials)) + .withRegion(region) + .build(); + } +} \ No newline at end of file diff --git a/src/main/java/com/jojoidu/book/easy/store/controller/ImageController.java b/src/main/java/com/jojoidu/book/easy/store/controller/ImageController.java new file mode 100644 index 0000000..37b8240 --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/store/controller/ImageController.java @@ -0,0 +1,60 @@ +package com.jojoidu.book.easy.store.controller; + +import com.jojoidu.book.easy.store.dto.MenuImageResponse; +import com.jojoidu.book.easy.store.dto.OptionImageResponse; +import com.jojoidu.book.easy.store.service.ImageService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +@Tag(name = "storeImage", description = "이미지 업로드 API") +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/v1/stores/uploadImage") +public class ImageController { + + private final ImageService imageService; + + @PostMapping("/menu/{menuId}") + @Operation(summary = "메뉴 이미지 업로드") + public ResponseEntity uploadMenuImage( + @Parameter(description = "메뉴 ID", example = "1") + @PathVariable("menuId") Long menuId, + @Parameter(description = "업로드할 이미지 파일") + @RequestParam("image") MultipartFile image) { + + try { + MenuImageResponse response = imageService.uploadMenuImage(menuId, image); + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(new MenuImageResponse(menuId, "이미지 업로드 중 오류가 발생했습니다.")); + } + } + + @PostMapping("/menu/{menuId}/option/{optionId}") + @Operation(summary = "옵션 이미지 업로드") + public ResponseEntity uploadOptionImage( + @Parameter(description = "옵션 ID", example = "1") + @PathVariable("menuId") Long menuId, + @Parameter(description = "옵션 ID", example = "1") + @PathVariable("optionId") Long optionId, + @Parameter(description = "업로드할 이미지 파일") + @RequestParam("image") MultipartFile image) { + + try { + OptionImageResponse response = imageService.uploadOptionImage(menuId, optionId, image); + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(new OptionImageResponse(menuId, optionId, "이미지 업로드 중 오류가 발생했습니다.")); + } + } +} diff --git a/src/main/java/com/jojoidu/book/easy/store/controller/StoreController.java b/src/main/java/com/jojoidu/book/easy/store/controller/StoreController.java index ccee81d..e65de9e 100644 --- a/src/main/java/com/jojoidu/book/easy/store/controller/StoreController.java +++ b/src/main/java/com/jojoidu/book/easy/store/controller/StoreController.java @@ -1,10 +1,11 @@ package com.jojoidu.book.easy.store.controller; -import com.jojoidu.book.easy.auth.docs.LoginAuthExceptionDocs; import com.jojoidu.book.easy.global.annotation.ApiErrorExceptionsExample; import com.jojoidu.book.easy.global.dto.ApiResponse; import com.jojoidu.book.easy.store.docs.StoreSearchExceptionDocs; +import com.jojoidu.book.easy.store.dto.MenuDetailsResponse; +import com.jojoidu.book.easy.store.dto.MenuListResponse; import com.jojoidu.book.easy.store.dto.StoreResponse; import com.jojoidu.book.easy.store.service.StoreService; import io.swagger.v3.oas.annotations.Operation; @@ -12,14 +13,11 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; -@Tag(name = "store", description = "업종 API") +@Tag(name = "store", description = "업종, 메뉴, 옵션 관련 API") @RequiredArgsConstructor @RestController @RequestMapping("/api/v1/stores") @@ -38,4 +36,31 @@ public ResponseEntity>> getStores( return ResponseEntity.ok(ApiResponse.success(stores)); } + @GetMapping("/{storeId}/{category}/menus") + @Operation(summary = "설명/실습 업종 메뉴 조회", description = "설명/실습 가능한 업종의 메뉴를 조회합니다.") + public ResponseEntity> getMenuList( + @Parameter(description = "모드", example = "explain/practice") + @RequestParam(name = "mode") String mode, + @Parameter(description = "Store ID", example = "1") + @PathVariable Long storeId, + @Parameter(description = "Menu category", example = "시즌메뉴") + @RequestParam String category) { + + + MenuListResponse menuList = storeService.getMenuList(mode, storeId, category); + return ResponseEntity.ok(ApiResponse.success(menuList)); + } + + @GetMapping("/{storeId}/{category}/menus/{menuId}") + @Operation(summary = "설명/실습 업종 메뉴 상세 조회", description = "선택한 메뉴의 상세내용를 조회합니다.") + public ResponseEntity> getMenuDetails( + @Parameter(description = "모드", example = "explain/practice") + @RequestParam(name = "mode") String mode, + @Parameter(description = "Menu ID", example = "1") + @PathVariable Long menuId) { + + + MenuDetailsResponse menuDetails = storeService.getMenuDetails(mode, menuId); + return ResponseEntity.ok(ApiResponse.success(menuDetails)); + } } diff --git a/src/main/java/com/jojoidu/book/easy/store/dto/MenuDetailsResponse.java b/src/main/java/com/jojoidu/book/easy/store/dto/MenuDetailsResponse.java new file mode 100644 index 0000000..4825ef7 --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/store/dto/MenuDetailsResponse.java @@ -0,0 +1,44 @@ +package com.jojoidu.book.easy.store.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class MenuDetailsResponse { + + @Schema(description = "메뉴 이름", example = "방어 사시미") + private String menuName; + + @Schema(description = "메뉴 가격", example = "40000") + private Integer menuPrice; + + @Schema(description = "메뉴 이미지 url", example = "https://groomiz.com/menu/1.jpg") + private String imageUrl; + + @Schema(description = "메뉴 옵션") + private List options; + + @Getter + @AllArgsConstructor + public static class OptionResponse { + @Schema(description = "옵션 제목", example = "사이즈 옵션") + private String optionTitle; + + @Schema(description = "옵션 상세") + private List optionDetails; + } + + @Getter + @AllArgsConstructor + public static class OptionDetailResponse { + @Schema(description = "옵션 이름", example = "대") + private String optionName; + + @Schema(description = "옵션 가격", example = "12000") + private Integer optionPrice; + } +} diff --git a/src/main/java/com/jojoidu/book/easy/store/dto/MenuImageResponse.java b/src/main/java/com/jojoidu/book/easy/store/dto/MenuImageResponse.java new file mode 100644 index 0000000..d2a2b6e --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/store/dto/MenuImageResponse.java @@ -0,0 +1,19 @@ +package com.jojoidu.book.easy.store.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Schema(description = "메뉴 이미지 업로드 응답 DTO") +public class MenuImageResponse { + + @Schema(description = "옵션 ID", example = "101") + private Long menuId; + + @Schema(description = "이미지 URL", example = "https://groomiz.com/classroom/1.jpg") + private String imageUrl; +} diff --git a/src/main/java/com/jojoidu/book/easy/store/dto/MenuListResponse.java b/src/main/java/com/jojoidu/book/easy/store/dto/MenuListResponse.java new file mode 100644 index 0000000..572e2f6 --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/store/dto/MenuListResponse.java @@ -0,0 +1,39 @@ +package com.jojoidu.book.easy.store.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +@Schema(description = "메뉴 목록 조회 응답 DTO") +public class MenuListResponse { + + @Schema(description = "업종 ID", example = "1") + private Long storeId; + + @Schema(description = "메뉴 종류", example = "시즌 메뉴") + private String category; + + @Schema(description = "메뉴 목록") + private List menus; + + @Getter + @AllArgsConstructor + public static class MenuData { + + @Schema(description = "메뉴 ID", example = "1") + private Long menuId; + + @Schema(description = "메뉴 이름", example = "방어 사시미") + private String menuName; + + @Schema(description = "가격", example = "40000") + private Integer price; + + @Schema(description = "메뉴 이미지 url", example = "https://groomiz.com/menu/1.jpg") + private String imageUrl; + } +} \ No newline at end of file diff --git a/src/main/java/com/jojoidu/book/easy/store/dto/OptionImageResponse.java b/src/main/java/com/jojoidu/book/easy/store/dto/OptionImageResponse.java new file mode 100644 index 0000000..767bd5f --- /dev/null +++ b/src/main/java/com/jojoidu/book/easy/store/dto/OptionImageResponse.java @@ -0,0 +1,23 @@ +package com.jojoidu.book.easy.store.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Schema(description = "옵션 이미지 업로드 응답 DTO") +public class OptionImageResponse { + + @Schema(description = "메뉴 ID", example = "1") + private Long menuId; + + @Schema(description = "옵션 ID", example = "101") + private Long optionId; + + @Schema(description = "이미지 URL", example = "https://groomiz.com/classroom/1.jpg") + private String imageUrl; +} diff --git a/src/main/java/com/jojoidu/book/easy/store/entity/menu/Menu.java b/src/main/java/com/jojoidu/book/easy/store/entity/menu/Menu.java index 5c91e56..1d12319 100644 --- a/src/main/java/com/jojoidu/book/easy/store/entity/menu/Menu.java +++ b/src/main/java/com/jojoidu/book/easy/store/entity/menu/Menu.java @@ -1,11 +1,7 @@ package com.jojoidu.book.easy.store.entity.menu; import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.ArrayList; import java.util.List; @@ -14,6 +10,7 @@ @Entity @Getter +@Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor public class Menu { @@ -23,15 +20,15 @@ public class Menu { @Column(name = "menu_id", nullable = false) private Long id; + @Column(name = "category", nullable = false) + private String category; + @Column(name = "menu_name", nullable = false) private String name; @Column(name = "menu_price", nullable = false) private Integer price; - @Column(name = "description") - private String description; - @Column(name = "image_url") private String imageUrl; @@ -43,11 +40,12 @@ public class Menu { private Store store; @Builder - public Menu(String name, Integer price, String description, String imageUrl, List