From fbf6c1262613e357152a386b2c2116ea9c8cda1e Mon Sep 17 00:00:00 2001 From: dh28be Date: Sat, 1 Jun 2024 00:52:34 +0900 Subject: [PATCH] added restaurantInfo api v2 --- .gitignore | 2 +- .../unist/meal/controller/HomeController.java | 31 +- ...r.java => RestaurantInfoControllerV1.java} | 28 +- .../RestaurantInfoControllerV2WeekDay.java | 146 +++++++++ .../RestaurantInfoControllerV2WeekEnd.java | 146 +++++++++ .../repository/RestaurantInfoRepository.java | 9 - .../RestaurantInfoRepositoryCustom.java | 5 - .../domain/RestaurantInfoV1.java} | 8 +- .../RestaurantInfoRepositoryCustomV1.java | 5 + .../RestaurantInfoRepositoryImplV1.java} | 8 +- .../RestaurantInfoRepositoryV1.java | 9 + .../v2/domain/RestaurantInfoV2.java | 48 +++ .../restaurantInfo/v2/model/DayType.java | 15 + .../RestaurantInfoRepositoryCustomV2.java | 12 + .../RestaurantInfoRepositoryImplV2.java | 31 ++ .../RestaurantInfoRepositoryV2.java | 9 + .../hexa/unist/meal/service/ExcelService.java | 2 +- .../hexa/unist/meal/service/MainService.java | 4 +- .../meal/service/RestaurantInfoService.java | 29 -- .../meal/service/RestaurantInfoServiceV1.java | 29 ++ .../RestaurantInfoServiceV2WeekDay.java | 30 ++ .../RestaurantInfoServiceV2WeekEnd.java | 30 ++ .../meal/service/dto/RestaurantInfoDto.java | 23 -- .../meal/service/dto/RestaurantInfoDtoV1.java | 23 ++ .../meal/service/dto/RestaurantInfoDtoV2.java | 23 ++ src/main/resources/application.yml | 3 +- src/main/resources/templates/adminPage.html | 290 +++++++++++++++++- was-logs/info.2024-05-31.0.log.gz | Bin 0 -> 7759 bytes 28 files changed, 899 insertions(+), 99 deletions(-) rename src/main/java/pro/hexa/unist/meal/controller/{RestaurantInfoController.java => RestaurantInfoControllerV1.java} (79%) create mode 100644 src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekDay.java create mode 100644 src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekEnd.java delete mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepository.java delete mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryCustom.java rename src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/{domain/RestaurantInfo.java => v1/domain/RestaurantInfoV1.java} (70%) create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryCustomV1.java rename src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/{repository/RestaurantInfoRepositoryImpl.java => v1/repository/RestaurantInfoRepositoryImplV1.java} (55%) create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryV1.java create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/domain/RestaurantInfoV2.java create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/model/DayType.java create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryCustomV2.java create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryImplV2.java create mode 100644 src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryV2.java delete mode 100644 src/main/java/pro/hexa/unist/meal/service/RestaurantInfoService.java create mode 100644 src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV1.java create mode 100644 src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekDay.java create mode 100644 src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekEnd.java delete mode 100644 src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDto.java create mode 100644 src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV1.java create mode 100644 src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV2.java create mode 100644 was-logs/info.2024-05-31.0.log.gz diff --git a/.gitignore b/.gitignore index 6c7a3ac..d5cf5a6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ build/ out/ logs/ -#src/main/resources/application.yml \ No newline at end of file +.env \ No newline at end of file diff --git a/src/main/java/pro/hexa/unist/meal/controller/HomeController.java b/src/main/java/pro/hexa/unist/meal/controller/HomeController.java index dac1532..e50e584 100644 --- a/src/main/java/pro/hexa/unist/meal/controller/HomeController.java +++ b/src/main/java/pro/hexa/unist/meal/controller/HomeController.java @@ -9,9 +9,12 @@ import org.springframework.web.bind.annotation.*; import pro.hexa.unist.meal.domain.mealTable.domain.MealTable; import pro.hexa.unist.meal.service.MealTableService; -import pro.hexa.unist.meal.service.RestaurantInfoService; +import pro.hexa.unist.meal.service.RestaurantInfoServiceV1; +import pro.hexa.unist.meal.service.RestaurantInfoServiceV2WeekDay; +import pro.hexa.unist.meal.service.RestaurantInfoServiceV2WeekEnd; import pro.hexa.unist.meal.service.dto.MealTableDto; -import pro.hexa.unist.meal.service.dto.RestaurantInfoDto; +import pro.hexa.unist.meal.service.dto.RestaurantInfoDtoV1; +import pro.hexa.unist.meal.service.dto.RestaurantInfoDtoV2; @RestController @RequestMapping("") @@ -20,7 +23,9 @@ public class HomeController { private final MealTableService mealTableService; - private final RestaurantInfoService restaurantInfoService; + private final RestaurantInfoServiceV1 restaurantInfoServiceV1; + private final RestaurantInfoServiceV2WeekDay restaurantInfoServiceV2WeekDay; + private final RestaurantInfoServiceV2WeekEnd restaurantInfoServiceV2WeekEnd; @GetMapping("/health") public ResponseEntity healthCheck() { @@ -44,9 +49,25 @@ public ResponseEntity> menuListResponseEntity(@RequestParam(r } @GetMapping("/mainpage/restaurantInfo") - public ResponseEntity restaurantInfoResponseEntity() { + public ResponseEntity restaurantInfoV1ResponseEntity() { - RestaurantInfoDto restaurantInfo = restaurantInfoService.findAll(); + RestaurantInfoDtoV1 restaurantInfo = restaurantInfoServiceV1.findAll(); + + return new ResponseEntity<>(restaurantInfo, HttpStatus.OK); + } + + @GetMapping("/mainpage/restaurantInfo/weekDay") + public ResponseEntity restaurantInfoV1WeekDayResponseEntity() { + + RestaurantInfoDtoV2 restaurantInfo = restaurantInfoServiceV2WeekDay.findAllWeekDay(); + + return new ResponseEntity<>(restaurantInfo, HttpStatus.OK); + } + + @GetMapping("/mainpage/restaurantInfo/weekEnd") + public ResponseEntity restaurantInfoV1WeekEndResponseEntity() { + + RestaurantInfoDtoV2 restaurantInfo = restaurantInfoServiceV2WeekEnd.findAllWeekEnd(); return new ResponseEntity<>(restaurantInfo, HttpStatus.OK); } diff --git a/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoController.java b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV1.java similarity index 79% rename from src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoController.java rename to src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV1.java index 7ff44dd..09f8ca1 100644 --- a/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoController.java +++ b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV1.java @@ -7,8 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import pro.hexa.unist.meal.domain.restaurantInfo.domain.RestaurantInfo; -import pro.hexa.unist.meal.domain.restaurantInfo.repository.RestaurantInfoRepository; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.domain.RestaurantInfoV1; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.repository.RestaurantInfoRepositoryV1; import pro.hexa.unist.meal.service.MainService; import javax.transaction.Transactional; @@ -19,10 +19,10 @@ @RequestMapping("/restaurantInfo") @RequiredArgsConstructor @Transactional -public class RestaurantInfoController { +public class RestaurantInfoControllerV1 { - private static final Logger log = LoggerFactory.getLogger(RestaurantInfoController.class); - private final RestaurantInfoRepository repository; + private static final Logger log = LoggerFactory.getLogger(RestaurantInfoControllerV1.class); + private final RestaurantInfoRepositoryV1 repository; private final MainService mainService; @PostMapping("/dormitoryKorean") @@ -113,27 +113,27 @@ private void uploadRestaurantInfo(String restaurantName, String breakfastStartTi mainService.verifySecretKey(theKey); - RestaurantInfo breakfast; - RestaurantInfo lunch; - RestaurantInfo dinner; + RestaurantInfoV1 breakfast; + RestaurantInfoV1 lunch; + RestaurantInfoV1 dinner; if (breakfastIsOpened != null) { String[] parsedBreakfastStartTime = breakfastStartTime.split(":"); String[] parsedBreakfastEndTime = breakfastEndTime.split(":"); - breakfast = new RestaurantInfo(restaurantName, breakfastPrice, true, Integer.parseInt(parsedBreakfastStartTime[0]), Integer.parseInt(parsedBreakfastStartTime[1]), Integer.parseInt(parsedBreakfastEndTime[0]), Integer.parseInt(parsedBreakfastEndTime[1]), "breakfast"); - } else breakfast = new RestaurantInfo(restaurantName, false, "breakfast"); + breakfast = new RestaurantInfoV1(restaurantName, breakfastPrice, true, Integer.parseInt(parsedBreakfastStartTime[0]), Integer.parseInt(parsedBreakfastStartTime[1]), Integer.parseInt(parsedBreakfastEndTime[0]), Integer.parseInt(parsedBreakfastEndTime[1]), "breakfast"); + } else breakfast = new RestaurantInfoV1(restaurantName, false, "breakfast"); if (lunchIsOpened != null) { String[] parsedLunchStartTime = lunchStartTime.split(":"); String[] parsedLunchEndTime = lunchEndTime.split(":"); - lunch = new RestaurantInfo(restaurantName, lunchPrice, lunchIsOpened, Integer.parseInt(parsedLunchStartTime[0]), Integer.parseInt(parsedLunchStartTime[1]), Integer.parseInt(parsedLunchEndTime[0]), Integer.parseInt(parsedLunchEndTime[1]), "lunch"); - } else lunch = new RestaurantInfo(restaurantName, false, "lunch"); + lunch = new RestaurantInfoV1(restaurantName, lunchPrice, lunchIsOpened, Integer.parseInt(parsedLunchStartTime[0]), Integer.parseInt(parsedLunchStartTime[1]), Integer.parseInt(parsedLunchEndTime[0]), Integer.parseInt(parsedLunchEndTime[1]), "lunch"); + } else lunch = new RestaurantInfoV1(restaurantName, false, "lunch"); if (dinnerIsOpened != null) { String[] parsedDinnerStartTime = dinnerStartTime.split(":"); String[] parsedDinnerEndTime = dinnerEndTime.split(":"); - dinner = new RestaurantInfo(restaurantName, dinnerPrice, dinnerIsOpened, Integer.parseInt(parsedDinnerStartTime[0]), Integer.parseInt(parsedDinnerStartTime[1]), Integer.parseInt(parsedDinnerEndTime[0]), Integer.parseInt(parsedDinnerEndTime[1]), "dinner"); - } else dinner = new RestaurantInfo(restaurantName, false, "dinner"); + dinner = new RestaurantInfoV1(restaurantName, dinnerPrice, dinnerIsOpened, Integer.parseInt(parsedDinnerStartTime[0]), Integer.parseInt(parsedDinnerStartTime[1]), Integer.parseInt(parsedDinnerEndTime[0]), Integer.parseInt(parsedDinnerEndTime[1]), "dinner"); + } else dinner = new RestaurantInfoV1(restaurantName, false, "dinner"); repository.deleteByRestaurantName(restaurantName); repository.save(breakfast); diff --git a/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekDay.java b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekDay.java new file mode 100644 index 0000000..f1cc4fa --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekDay.java @@ -0,0 +1,146 @@ +package pro.hexa.unist.meal.controller; + +import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.repository.RestaurantInfoRepositoryV2; +import pro.hexa.unist.meal.service.MainService; + +import javax.transaction.Transactional; +import java.net.URI; +import java.net.URISyntaxException; + +@RestController +@RequestMapping("/restaurantInfo/weekDay") +@RequiredArgsConstructor +@Transactional +public class RestaurantInfoControllerV2WeekDay { + + private static final Logger log = LoggerFactory.getLogger(RestaurantInfoControllerV2WeekDay.class); + private final RestaurantInfoRepositoryV2 repository; + private final MainService mainService; + + @PostMapping("/dormitoryKorean") + public ResponseEntity saveDormitoryKoreanRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("기숙사 식당(한식)", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/dormitoryHalal") + public ResponseEntity saveDormitoryHalalRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("기숙사 식당(할랄)", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/student") + public ResponseEntity saveStudentRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("학생 식당", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/professor") + public ResponseEntity saveProfessorRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("교직원 식당", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + private void uploadRestaurantInfo(String restaurantName, String breakfastStartTime, String breakfastEndTime, Integer breakfastPrice, Boolean breakfastIsOpened, String lunchStartTime, String lunchEndTime, Integer lunchPrice, Boolean lunchIsOpened, String dinnerStartTime, String dinnerEndTime, Integer dinnerPrice, Boolean dinnerIsOpened, String theKey) { + + mainService.verifySecretKey(theKey); + + RestaurantInfoV2 breakfast; + RestaurantInfoV2 lunch; + RestaurantInfoV2 dinner; + + if (breakfastIsOpened != null) { + String[] parsedBreakfastStartTime = breakfastStartTime.split(":"); + String[] parsedBreakfastEndTime = breakfastEndTime.split(":"); + breakfast = new RestaurantInfoV2(restaurantName, breakfastPrice, true, Integer.parseInt(parsedBreakfastStartTime[0]), Integer.parseInt(parsedBreakfastStartTime[1]), Integer.parseInt(parsedBreakfastEndTime[0]), Integer.parseInt(parsedBreakfastEndTime[1]), "breakfast", DayType.WEEKDAY); + } else breakfast = new RestaurantInfoV2(restaurantName, false, "breakfast", DayType.WEEKDAY); + + if (lunchIsOpened != null) { + String[] parsedLunchStartTime = lunchStartTime.split(":"); + String[] parsedLunchEndTime = lunchEndTime.split(":"); + lunch = new RestaurantInfoV2(restaurantName, lunchPrice, lunchIsOpened, Integer.parseInt(parsedLunchStartTime[0]), Integer.parseInt(parsedLunchStartTime[1]), Integer.parseInt(parsedLunchEndTime[0]), Integer.parseInt(parsedLunchEndTime[1]), "lunch", DayType.WEEKDAY); + } else lunch = new RestaurantInfoV2(restaurantName, false, "lunch", DayType.WEEKDAY); + + if (dinnerIsOpened != null) { + String[] parsedDinnerStartTime = dinnerStartTime.split(":"); + String[] parsedDinnerEndTime = dinnerEndTime.split(":"); + dinner = new RestaurantInfoV2(restaurantName, dinnerPrice, dinnerIsOpened, Integer.parseInt(parsedDinnerStartTime[0]), Integer.parseInt(parsedDinnerStartTime[1]), Integer.parseInt(parsedDinnerEndTime[0]), Integer.parseInt(parsedDinnerEndTime[1]), "dinner", DayType.WEEKDAY); + } else dinner = new RestaurantInfoV2(restaurantName, false, "dinner", DayType.WEEKDAY); + + repository.deleteByRestaurantNameAndDayType(restaurantName, DayType.WEEKDAY); + repository.save(breakfast); + repository.save(lunch); + repository.save(dinner); + + log.info("{} restaurant info uploaded", restaurantName); + } +} diff --git a/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekEnd.java b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekEnd.java new file mode 100644 index 0000000..c3dc49d --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/controller/RestaurantInfoControllerV2WeekEnd.java @@ -0,0 +1,146 @@ +package pro.hexa.unist.meal.controller; + +import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.repository.RestaurantInfoRepositoryV2; +import pro.hexa.unist.meal.service.MainService; + +import javax.transaction.Transactional; +import java.net.URI; +import java.net.URISyntaxException; + +@RestController +@RequestMapping("/restaurantInfo/weekEnd") +@RequiredArgsConstructor +@Transactional +public class RestaurantInfoControllerV2WeekEnd { + + private static final Logger log = LoggerFactory.getLogger(RestaurantInfoControllerV2WeekEnd.class); + private final RestaurantInfoRepositoryV2 repository; + private final MainService mainService; + + @PostMapping("/dormitoryKorean") + public ResponseEntity saveDormitoryKoreanRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("기숙사 식당(한식)", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/dormitoryHalal") + public ResponseEntity saveDormitoryHalalRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("기숙사 식당(할랄)", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/student") + public ResponseEntity saveStudentRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("학생 식당", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + @PostMapping("/professor") + public ResponseEntity saveProfessorRestaurantInfo( + String breakfastStartTime, + String breakfastEndTime, + Integer breakfastPrice, + Boolean breakfastIsOpened, + String lunchStartTime, + String lunchEndTime, + Integer lunchPrice, + Boolean lunchIsOpened, + String dinnerStartTime, + String dinnerEndTime, + Integer dinnerPrice, + Boolean dinnerIsOpened, + String theKey + ) throws URISyntaxException { + + uploadRestaurantInfo("교직원 식당", breakfastStartTime, breakfastEndTime, breakfastPrice, breakfastIsOpened, lunchStartTime, lunchEndTime, lunchPrice, lunchIsOpened, dinnerStartTime, dinnerEndTime, dinnerPrice, dinnerIsOpened, theKey); + return ResponseEntity.created(new URI("/importSuccess")).build(); + } + + private void uploadRestaurantInfo(String restaurantName, String breakfastStartTime, String breakfastEndTime, Integer breakfastPrice, Boolean breakfastIsOpened, String lunchStartTime, String lunchEndTime, Integer lunchPrice, Boolean lunchIsOpened, String dinnerStartTime, String dinnerEndTime, Integer dinnerPrice, Boolean dinnerIsOpened, String theKey) { + + mainService.verifySecretKey(theKey); + + RestaurantInfoV2 breakfast; + RestaurantInfoV2 lunch; + RestaurantInfoV2 dinner; + + if (breakfastIsOpened != null) { + String[] parsedBreakfastStartTime = breakfastStartTime.split(":"); + String[] parsedBreakfastEndTime = breakfastEndTime.split(":"); + breakfast = new RestaurantInfoV2(restaurantName, breakfastPrice, true, Integer.parseInt(parsedBreakfastStartTime[0]), Integer.parseInt(parsedBreakfastStartTime[1]), Integer.parseInt(parsedBreakfastEndTime[0]), Integer.parseInt(parsedBreakfastEndTime[1]), "breakfast", DayType.WEEKEND); + } else breakfast = new RestaurantInfoV2(restaurantName, false, "breakfast", DayType.WEEKEND); + + if (lunchIsOpened != null) { + String[] parsedLunchStartTime = lunchStartTime.split(":"); + String[] parsedLunchEndTime = lunchEndTime.split(":"); + lunch = new RestaurantInfoV2(restaurantName, lunchPrice, lunchIsOpened, Integer.parseInt(parsedLunchStartTime[0]), Integer.parseInt(parsedLunchStartTime[1]), Integer.parseInt(parsedLunchEndTime[0]), Integer.parseInt(parsedLunchEndTime[1]), "lunch", DayType.WEEKEND); + } else lunch = new RestaurantInfoV2(restaurantName, false, "lunch", DayType.WEEKEND); + + if (dinnerIsOpened != null) { + String[] parsedDinnerStartTime = dinnerStartTime.split(":"); + String[] parsedDinnerEndTime = dinnerEndTime.split(":"); + dinner = new RestaurantInfoV2(restaurantName, dinnerPrice, dinnerIsOpened, Integer.parseInt(parsedDinnerStartTime[0]), Integer.parseInt(parsedDinnerStartTime[1]), Integer.parseInt(parsedDinnerEndTime[0]), Integer.parseInt(parsedDinnerEndTime[1]), "dinner", DayType.WEEKEND); + } else dinner = new RestaurantInfoV2(restaurantName, false, "dinner", DayType.WEEKEND); + + repository.deleteByRestaurantNameAndDayType(restaurantName, DayType.WEEKEND); + repository.save(breakfast); + repository.save(lunch); + repository.save(dinner); + + log.info("{} restaurant info uploaded", restaurantName); + } +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepository.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepository.java deleted file mode 100644 index 51841ff..0000000 --- a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package pro.hexa.unist.meal.domain.restaurantInfo.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import pro.hexa.unist.meal.domain.restaurantInfo.domain.RestaurantInfo; - -@Repository -public interface RestaurantInfoRepository extends JpaRepository, RestaurantInfoRepositoryCustom { -} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryCustom.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryCustom.java deleted file mode 100644 index 3248d58..0000000 --- a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryCustom.java +++ /dev/null @@ -1,5 +0,0 @@ -package pro.hexa.unist.meal.domain.restaurantInfo.repository; - -public interface RestaurantInfoRepositoryCustom { - void deleteByRestaurantName(String restaurantName); -} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/domain/RestaurantInfo.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/domain/RestaurantInfoV1.java similarity index 70% rename from src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/domain/RestaurantInfo.java rename to src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/domain/RestaurantInfoV1.java index f709d77..264cb4e 100644 --- a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/domain/RestaurantInfo.java +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/domain/RestaurantInfoV1.java @@ -1,4 +1,4 @@ -package pro.hexa.unist.meal.domain.restaurantInfo.domain; +package pro.hexa.unist.meal.domain.restaurantInfo.v1.domain; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +9,7 @@ @Entity @Getter @NoArgsConstructor -public class RestaurantInfo extends AbstractEntity { +public class RestaurantInfoV1 extends AbstractEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -23,7 +23,7 @@ public class RestaurantInfo extends AbstractEntity { private Integer endTimeMinute; private String mealType; - public RestaurantInfo(String restaurantName, Integer price, Boolean isOpened, Integer startTimeHour, Integer startTimeMinute, Integer endTimeHour, Integer endTimeMinute, String mealType) { + public RestaurantInfoV1(String restaurantName, Integer price, Boolean isOpened, Integer startTimeHour, Integer startTimeMinute, Integer endTimeHour, Integer endTimeMinute, String mealType) { this.restaurantName = restaurantName; this.price = price; this.isOpened = isOpened; @@ -34,7 +34,7 @@ public RestaurantInfo(String restaurantName, Integer price, Boolean isOpened, In this.mealType = mealType; } - public RestaurantInfo(String restaurantName, Boolean isOpened, String mealType) { + public RestaurantInfoV1(String restaurantName, Boolean isOpened, String mealType) { this.restaurantName = restaurantName; this.isOpened = isOpened; this.mealType = mealType; diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryCustomV1.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryCustomV1.java new file mode 100644 index 0000000..df1a78b --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryCustomV1.java @@ -0,0 +1,5 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v1.repository; + +public interface RestaurantInfoRepositoryCustomV1 { + void deleteByRestaurantName(String restaurantName); +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryImpl.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryImplV1.java similarity index 55% rename from src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryImpl.java rename to src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryImplV1.java index 7b07c55..b237232 100644 --- a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/repository/RestaurantInfoRepositoryImpl.java +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryImplV1.java @@ -1,16 +1,16 @@ -package pro.hexa.unist.meal.domain.restaurantInfo.repository; +package pro.hexa.unist.meal.domain.restaurantInfo.v1.repository; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import pro.hexa.unist.meal.domain.restaurantInfo.domain.QRestaurantInfo; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.domain.QRestaurantInfoV1; @RequiredArgsConstructor -public class RestaurantInfoRepositoryImpl implements RestaurantInfoRepositoryCustom { +public class RestaurantInfoRepositoryImplV1 implements RestaurantInfoRepositoryCustomV1 { private final JPAQueryFactory queryFactory; @Override public void deleteByRestaurantName(String restaurantName) { - QRestaurantInfo restaurantInfo = QRestaurantInfo.restaurantInfo; + QRestaurantInfoV1 restaurantInfo = QRestaurantInfoV1.restaurantInfoV1; queryFactory.delete(restaurantInfo) .where(restaurantInfo.restaurantName.eq(restaurantName)) .execute(); diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryV1.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryV1.java new file mode 100644 index 0000000..a80409e --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v1/repository/RestaurantInfoRepositoryV1.java @@ -0,0 +1,9 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v1.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.domain.RestaurantInfoV1; + +@Repository +public interface RestaurantInfoRepositoryV1 extends JpaRepository, RestaurantInfoRepositoryCustomV1 { +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/domain/RestaurantInfoV2.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/domain/RestaurantInfoV2.java new file mode 100644 index 0000000..61407fa --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/domain/RestaurantInfoV2.java @@ -0,0 +1,48 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v2.domain; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import pro.hexa.unist.meal.domain.AbstractEntity; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; + +import javax.persistence.*; + +@Entity +@Getter +@NoArgsConstructor +public class RestaurantInfoV2 extends AbstractEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String restaurantName; + private Integer price; + private Boolean isOpened; + private Integer startTimeHour; + private Integer startTimeMinute; + private Integer endTimeHour; + private Integer endTimeMinute; + private String mealType; + + @Enumerated(EnumType.STRING) + private DayType dayType; + + public RestaurantInfoV2(String restaurantName, Integer price, Boolean isOpened, Integer startTimeHour, Integer startTimeMinute, Integer endTimeHour, Integer endTimeMinute, String mealType, DayType dayType) { + this.restaurantName = restaurantName; + this.price = price; + this.isOpened = isOpened; + this.startTimeHour = startTimeHour; + this.startTimeMinute = startTimeMinute; + this.endTimeHour = endTimeHour; + this.endTimeMinute = endTimeMinute; + this.mealType = mealType; + this.dayType = dayType; + } + + public RestaurantInfoV2(String restaurantName, Boolean isOpened, String mealType, DayType dayType) { + this.restaurantName = restaurantName; + this.isOpened = isOpened; + this.mealType = mealType; + this.dayType = dayType; + } +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/model/DayType.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/model/DayType.java new file mode 100644 index 0000000..6bf59b4 --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/model/DayType.java @@ -0,0 +1,15 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v2.model; + +import lombok.Getter; + +@Getter +public enum DayType { + WEEKDAY(0), + WEEKEND(1); + + private final int value; + + DayType(int value) { + this.value = value; + } +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryCustomV2.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryCustomV2.java new file mode 100644 index 0000000..62c09eb --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryCustomV2.java @@ -0,0 +1,12 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v2.repository; + +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; + +import java.util.List; + +public interface RestaurantInfoRepositoryCustomV2 { + void deleteByRestaurantNameAndDayType(String restaurantName, DayType dayType); + + List findByDayType(DayType dayType); +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryImplV2.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryImplV2.java new file mode 100644 index 0000000..dc0497f --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryImplV2.java @@ -0,0 +1,31 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v2.repository; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.QRestaurantInfoV2; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; + +import java.util.List; + +@RequiredArgsConstructor +public class RestaurantInfoRepositoryImplV2 implements RestaurantInfoRepositoryCustomV2 { + private final JPAQueryFactory queryFactory; + + @Override + public void deleteByRestaurantNameAndDayType(String restaurantName, DayType dayType) { + QRestaurantInfoV2 restaurantInfo = QRestaurantInfoV2.restaurantInfoV2; + queryFactory.delete(restaurantInfo) + .where(restaurantInfo.restaurantName.eq(restaurantName)) + .where(restaurantInfo.dayType.eq(dayType)) + .execute(); + } + + @Override + public List findByDayType(DayType dayType) { + QRestaurantInfoV2 restaurantInfo = QRestaurantInfoV2.restaurantInfoV2; + return queryFactory.selectFrom(restaurantInfo) + .where(restaurantInfo.dayType.eq(dayType)) + .fetch(); + } +} diff --git a/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryV2.java b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryV2.java new file mode 100644 index 0000000..b2076cb --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/domain/restaurantInfo/v2/repository/RestaurantInfoRepositoryV2.java @@ -0,0 +1,9 @@ +package pro.hexa.unist.meal.domain.restaurantInfo.v2.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; + +@Repository +public interface RestaurantInfoRepositoryV2 extends JpaRepository, RestaurantInfoRepositoryCustomV2 { +} diff --git a/src/main/java/pro/hexa/unist/meal/service/ExcelService.java b/src/main/java/pro/hexa/unist/meal/service/ExcelService.java index 537278c..cfba115 100644 --- a/src/main/java/pro/hexa/unist/meal/service/ExcelService.java +++ b/src/main/java/pro/hexa/unist/meal/service/ExcelService.java @@ -27,7 +27,7 @@ public class ExcelService { private final DBWriteService dbWriteService; - @Value("${secretKey}") + @Value("${SECRET_KEY}") String secretKey; @Transactional diff --git a/src/main/java/pro/hexa/unist/meal/service/MainService.java b/src/main/java/pro/hexa/unist/meal/service/MainService.java index a108536..67c835b 100644 --- a/src/main/java/pro/hexa/unist/meal/service/MainService.java +++ b/src/main/java/pro/hexa/unist/meal/service/MainService.java @@ -14,11 +14,13 @@ @RequiredArgsConstructor public class MainService { - @Value("${secretKey}") + @Value("${SECRET_KEY}") String secretKey; public void verifySecretKey(String key) { if (!secretKey.equals(key)) { + log.error("{}", key); + log.error("{}", secretKey); throw new BadRequestException(BadRequestType.WRONG_SECRET_KEY); } } diff --git a/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoService.java b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoService.java deleted file mode 100644 index 405f281..0000000 --- a/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoService.java +++ /dev/null @@ -1,29 +0,0 @@ -package pro.hexa.unist.meal.service; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import pro.hexa.unist.meal.domain.restaurantInfo.repository.RestaurantInfoRepository; -import pro.hexa.unist.meal.service.dto.RestaurantInfoDto; - -@Service -@RequiredArgsConstructor -public class RestaurantInfoService { - private final RestaurantInfoRepository restaurantInfoRepository; - - public RestaurantInfoDto findAll() { - - RestaurantInfoDto restaurantInfoDto = new RestaurantInfoDto(); - - restaurantInfoRepository.findAll() - .forEach(restaurantInfo -> { - if (restaurantInfo.getMealType().equals("breakfast")) - restaurantInfoDto.getBreakfast().add(restaurantInfo); - else if (restaurantInfo.getMealType().equals("lunch")) - restaurantInfoDto.getLunch().add(restaurantInfo); - else if (restaurantInfo.getMealType().equals("dinner")) - restaurantInfoDto.getDinner().add(restaurantInfo); - }); - - return restaurantInfoDto; - } -} diff --git a/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV1.java b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV1.java new file mode 100644 index 0000000..ee28819 --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV1.java @@ -0,0 +1,29 @@ +package pro.hexa.unist.meal.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.repository.RestaurantInfoRepositoryV1; +import pro.hexa.unist.meal.service.dto.RestaurantInfoDtoV1; + +@Service +@RequiredArgsConstructor +public class RestaurantInfoServiceV1 { + private final RestaurantInfoRepositoryV1 restaurantInfoRepositoryV1; + + public RestaurantInfoDtoV1 findAll() { + + RestaurantInfoDtoV1 restaurantInfoDtoV1 = new RestaurantInfoDtoV1(); + + restaurantInfoRepositoryV1.findAll() + .forEach(restaurantInfo -> { + if (restaurantInfo.getMealType().equals("breakfast")) + restaurantInfoDtoV1.getBreakfast().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("lunch")) + restaurantInfoDtoV1.getLunch().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("dinner")) + restaurantInfoDtoV1.getDinner().add(restaurantInfo); + }); + + return restaurantInfoDtoV1; + } +} diff --git a/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekDay.java b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekDay.java new file mode 100644 index 0000000..ba8b27e --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekDay.java @@ -0,0 +1,30 @@ +package pro.hexa.unist.meal.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.repository.RestaurantInfoRepositoryV2; +import pro.hexa.unist.meal.service.dto.RestaurantInfoDtoV2; + +@Service +@RequiredArgsConstructor +public class RestaurantInfoServiceV2WeekDay { + private final RestaurantInfoRepositoryV2 restaurantInfoRepositoryV2; + + public RestaurantInfoDtoV2 findAllWeekDay() { + + RestaurantInfoDtoV2 restaurantInfoDtoV2 = new RestaurantInfoDtoV2(); + + restaurantInfoRepositoryV2.findByDayType(DayType.WEEKDAY) + .forEach(restaurantInfo -> { + if (restaurantInfo.getMealType().equals("breakfast")) + restaurantInfoDtoV2.getBreakfast().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("lunch")) + restaurantInfoDtoV2.getLunch().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("dinner")) + restaurantInfoDtoV2.getDinner().add(restaurantInfo); + }); + + return restaurantInfoDtoV2; + } +} diff --git a/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekEnd.java b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekEnd.java new file mode 100644 index 0000000..6df4c39 --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/service/RestaurantInfoServiceV2WeekEnd.java @@ -0,0 +1,30 @@ +package pro.hexa.unist.meal.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.model.DayType; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.repository.RestaurantInfoRepositoryV2; +import pro.hexa.unist.meal.service.dto.RestaurantInfoDtoV2; + +@Service +@RequiredArgsConstructor +public class RestaurantInfoServiceV2WeekEnd { + private final RestaurantInfoRepositoryV2 restaurantInfoRepositoryV2; + + public RestaurantInfoDtoV2 findAllWeekEnd() { + + RestaurantInfoDtoV2 restaurantInfoDtoV2 = new RestaurantInfoDtoV2(); + + restaurantInfoRepositoryV2.findByDayType(DayType.WEEKEND) + .forEach(restaurantInfo -> { + if (restaurantInfo.getMealType().equals("breakfast")) + restaurantInfoDtoV2.getBreakfast().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("lunch")) + restaurantInfoDtoV2.getLunch().add(restaurantInfo); + else if (restaurantInfo.getMealType().equals("dinner")) + restaurantInfoDtoV2.getDinner().add(restaurantInfo); + }); + + return restaurantInfoDtoV2; + } +} diff --git a/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDto.java b/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDto.java deleted file mode 100644 index 30453b4..0000000 --- a/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package pro.hexa.unist.meal.service.dto; - -import lombok.Getter; -import lombok.Setter; -import pro.hexa.unist.meal.domain.restaurantInfo.domain.RestaurantInfo; - -import java.util.ArrayList; -import java.util.List; - -@Getter -@Setter -public class RestaurantInfoDto { - - private List breakfast; - private List lunch; - private List dinner; - - public RestaurantInfoDto() { - breakfast = new ArrayList<>(); - lunch = new ArrayList<>(); - dinner = new ArrayList<>(); - } -} diff --git a/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV1.java b/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV1.java new file mode 100644 index 0000000..6f1fe4f --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV1.java @@ -0,0 +1,23 @@ +package pro.hexa.unist.meal.service.dto; + +import lombok.Getter; +import lombok.Setter; +import pro.hexa.unist.meal.domain.restaurantInfo.v1.domain.RestaurantInfoV1; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +public class RestaurantInfoDtoV1 { + + private List breakfast; + private List lunch; + private List dinner; + + public RestaurantInfoDtoV1() { + breakfast = new ArrayList<>(); + lunch = new ArrayList<>(); + dinner = new ArrayList<>(); + } +} diff --git a/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV2.java b/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV2.java new file mode 100644 index 0000000..74d3867 --- /dev/null +++ b/src/main/java/pro/hexa/unist/meal/service/dto/RestaurantInfoDtoV2.java @@ -0,0 +1,23 @@ +package pro.hexa.unist.meal.service.dto; + +import lombok.Getter; +import lombok.Setter; +import pro.hexa.unist.meal.domain.restaurantInfo.v2.domain.RestaurantInfoV2; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +public class RestaurantInfoDtoV2 { + + private List breakfast; + private List lunch; + private List dinner; + + public RestaurantInfoDtoV2() { + breakfast = new ArrayList<>(); + lunch = new ArrayList<>(); + dinner = new ArrayList<>(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 47c58a4..57094ab 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,7 +18,7 @@ spring: config: activate: on-profile: default, development -secretKey: ${SECRET_KEY} + import: optional:file:.env[.properties] --- spring: config: @@ -28,7 +28,6 @@ spring: url: ${DATABASE_URL} username: ${DATABASE_USERNAME} password: ${DATABASE_PASSWORD} -secretKey: ${SECRET_KEY} --- spring: profiles: diff --git a/src/main/resources/templates/adminPage.html b/src/main/resources/templates/adminPage.html index 5d162f4..1cf09f9 100644 --- a/src/main/resources/templates/adminPage.html +++ b/src/main/resources/templates/adminPage.html @@ -118,7 +118,7 @@


- 식당 정보 업로드 + 식당 정보 업로드(V1)

@@ -259,6 +259,294 @@

교직원 식당

+
+ +

+ 식당 정보 업로드(V2, 평일) +

+ +
+
+
+

기숙사 식당(한식)

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

기숙사 식당(할랄)

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

학생 식당

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

교직원 식당

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+
+ +
+ +

+ 식당 정보 업로드(V2, 주말) +

+ +
+
+
+

기숙사 식당(한식)

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

기숙사 식당(할랄)

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

학생 식당

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+ +
+
+

교직원 식당

+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + +
+ +
+
+
+
+ diff --git a/was-logs/info.2024-05-31.0.log.gz b/was-logs/info.2024-05-31.0.log.gz new file mode 100644 index 0000000000000000000000000000000000000000..4a29f22206a9bd486cbe76e1c8b2cfd7448d4f32 GIT binary patch literal 7759 zcmZ8_RahKMuqEyu2yVgM-7N&S4DJLOeDJ~D-5~@C7BnzO&_NS|69#uDz@Whc%;x@g z_hsv$`*fYJzCJHi-Bt8SSV;dF;?%;;d-ZMROK{CtSbybvmMYHZOZD`%?z&7CiQH+w z;LK0GTv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