From 8225c368977936576e0d98f99c933030225b3824 Mon Sep 17 00:00:00 2001 From: lyh7712 <81278286+lyh7712@users.noreply.github.com> Date: Mon, 7 Jun 2021 23:43:15 +0900 Subject: [PATCH] =?UTF-8?q?#50=20package=20=EA=B5=AC=EC=A1=B0=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: MenuGroup(restaurant -> shop) 네이밍 수정 * style: rename restaurant -> shop * style: 빼먹은 부분 수정 * shop -> shop-shop Co-authored-by: soongjamm --- .../config/GlobalExceptionHandler.java | 1 - .../java/com/delivery/config/WebConfig.java | 14 ++-- .../restaurant/RestaurantRepository.java | 18 ----- .../RestaurantRepositoryMybatis.java | 69 ------------------- .../restaurant/RestaurantUpdateService.java | 51 -------------- .../businesshour/BusinessHourCondition.java | 10 --- .../businesshour/BusinessHour.java | 8 +-- .../businesshour/BusinessHourCondition.java | 10 +++ .../businesshour/BusinessHourConditions.java | 8 +-- .../businesshour/BusinessHourMapper.java | 4 +- .../businesshour/BusinessHourPolicy.java | 2 +- .../BusinessHourRequestParam.java | 4 +- .../BusinessHourRequestParams.java | 5 +- .../businesshour/BusinessHourResponse.java | 2 +- .../EverydayBusinessHourCondition.java | 6 +- .../businesshour/UpdateBusinessHoursDto.java | 3 +- .../WeekdayWeekendBusinessHourCondition.java | 6 +- .../{restaurant => shop}/menu/Menu.java | 2 +- .../menugroup => shop/menu}/MenuGroup.java | 12 ++-- .../menu}/MenuGroupController.java | 10 +-- .../menugroup => shop/menu}/MenuGroupDto.java | 22 +++--- .../menu}/MenuGroupMapper.java | 2 +- .../menu}/MenuGroupService.java | 2 +- .../shop}/EditPhoneDto.java | 2 +- .../shop}/EditPhoneRequest.java | 2 +- .../Restaurant.java => shop/shop/Shop.java} | 10 +-- .../shop/ShopMapper.java} | 6 +- .../delivery/shop/shop/ShopRepository.java | 18 +++++ .../shop/shop/ShopRepositoryMybatis.java | 69 +++++++++++++++++++ .../shop/ShopUpdateController.java} | 12 ++-- .../delivery/shop/shop/ShopUpdateService.java | 51 ++++++++++++++ src/main/resources/application.yml | 5 +- .../db/migration/V202106021837__init.sql | 36 ---------- ...106022120__editRestaurant_businessHour.sql | 18 ----- .../db/migration/V202106071728__init.sql | 40 +++++++++++ .../mybatis/mapper/BusinessHourMapper.xml | 10 +-- .../mybatis/mapper/MenuGroupMapper.xml | 8 +-- .../mybatis/mapper/RestaurantMapper.xml | 31 ++++----- .../BusinessHourPolicyConditionsTest.java | 18 +++-- .../menugroup/MenuGroupServiceTest.java | 8 ++- 40 files changed, 296 insertions(+), 319 deletions(-) delete mode 100644 src/main/java/com/delivery/restaurant/RestaurantRepository.java delete mode 100644 src/main/java/com/delivery/restaurant/RestaurantRepositoryMybatis.java delete mode 100644 src/main/java/com/delivery/restaurant/RestaurantUpdateService.java delete mode 100644 src/main/java/com/delivery/restaurant/businesshour/BusinessHourCondition.java rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHour.java (88%) create mode 100644 src/main/java/com/delivery/shop/businesshour/BusinessHourCondition.java rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourConditions.java (71%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourMapper.java (61%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourPolicy.java (94%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourRequestParam.java (86%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourRequestParams.java (88%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/BusinessHourResponse.java (90%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/EverydayBusinessHourCondition.java (78%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/UpdateBusinessHoursDto.java (92%) rename src/main/java/com/delivery/{restaurant => shop}/businesshour/WeekdayWeekendBusinessHourCondition.java (85%) rename src/main/java/com/delivery/{restaurant => shop}/menu/Menu.java (92%) rename src/main/java/com/delivery/{restaurant/menugroup => shop/menu}/MenuGroup.java (74%) rename src/main/java/com/delivery/{restaurant/menugroup => shop/menu}/MenuGroupController.java (78%) rename src/main/java/com/delivery/{restaurant/menugroup => shop/menu}/MenuGroupDto.java (65%) rename src/main/java/com/delivery/{restaurant/menugroup => shop/menu}/MenuGroupMapper.java (84%) rename src/main/java/com/delivery/{restaurant/menugroup => shop/menu}/MenuGroupService.java (94%) rename src/main/java/com/delivery/{restaurant => shop/shop}/EditPhoneDto.java (94%) rename src/main/java/com/delivery/{restaurant => shop/shop}/EditPhoneRequest.java (94%) rename src/main/java/com/delivery/{restaurant/Restaurant.java => shop/shop/Shop.java} (83%) rename src/main/java/com/delivery/{restaurant/RestaurantMapper.java => shop/shop/ShopMapper.java} (71%) create mode 100644 src/main/java/com/delivery/shop/shop/ShopRepository.java create mode 100644 src/main/java/com/delivery/shop/shop/ShopRepositoryMybatis.java rename src/main/java/com/delivery/{restaurant/RestaurantUpdateController.java => shop/shop/ShopUpdateController.java} (84%) create mode 100644 src/main/java/com/delivery/shop/shop/ShopUpdateService.java delete mode 100644 src/main/resources/db/migration/V202106021837__init.sql delete mode 100644 src/main/resources/db/migration/V202106022120__editRestaurant_businessHour.sql create mode 100644 src/main/resources/db/migration/V202106071728__init.sql rename src/test/java/com/delivery/{restaurant => shop}/BusinessHourPolicyConditionsTest.java (87%) rename src/test/java/com/delivery/{restaurant => shop}/menugroup/MenuGroupServiceTest.java (84%) diff --git a/src/main/java/com/delivery/config/GlobalExceptionHandler.java b/src/main/java/com/delivery/config/GlobalExceptionHandler.java index 55b62b8a..34564877 100644 --- a/src/main/java/com/delivery/config/GlobalExceptionHandler.java +++ b/src/main/java/com/delivery/config/GlobalExceptionHandler.java @@ -3,7 +3,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.apache.ibatis.javassist.NotFoundException; import org.springframework.dao.DuplicateKeyException; import org.springframework.http.ResponseEntity; import org.springframework.validation.FieldError; diff --git a/src/main/java/com/delivery/config/WebConfig.java b/src/main/java/com/delivery/config/WebConfig.java index 192499dd..a5238e17 100644 --- a/src/main/java/com/delivery/config/WebConfig.java +++ b/src/main/java/com/delivery/config/WebConfig.java @@ -5,10 +5,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import com.delivery.restaurant.RestaurantMapper; -import com.delivery.restaurant.RestaurantRepository; -import com.delivery.restaurant.RestaurantRepositoryMybatis; -import com.delivery.restaurant.businesshour.BusinessHourMapper; +import com.delivery.shop.businesshour.BusinessHourMapper; +import com.delivery.shop.shop.ShopMapper; +import com.delivery.shop.shop.ShopRepository; +import com.delivery.shop.shop.ShopRepositoryMybatis; import com.delivery.user.UserRepository; import com.delivery.user.UserRepositoryHashMap; @@ -19,7 +19,7 @@ public class WebConfig { @Profile("dev") static class DevConfig { @Autowired - private RestaurantMapper restaurantMapper; + private ShopMapper shopMapper; @Autowired private BusinessHourMapper businessHourMapper; @@ -29,8 +29,8 @@ public UserRepository userRepository() { } @Bean - public RestaurantRepository restaurantRepository() { - return new RestaurantRepositoryMybatis(restaurantMapper, businessHourMapper); + public ShopRepository shopRepository() { + return new ShopRepositoryMybatis(shopMapper, businessHourMapper); } } diff --git a/src/main/java/com/delivery/restaurant/RestaurantRepository.java b/src/main/java/com/delivery/restaurant/RestaurantRepository.java deleted file mode 100644 index 30ffca6a..00000000 --- a/src/main/java/com/delivery/restaurant/RestaurantRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.delivery.restaurant; - -import org.springframework.stereotype.Repository; - -@Repository -public interface RestaurantRepository { - Restaurant findRestaurantById(Long id); - - void updateBusinessHour(Restaurant restaurant); - - void updateIntroduce(Restaurant restaurant); - - void updatePhone(Restaurant restaurant); - - void updateDeliveryAreaGuide(Restaurant restaurant); - - void updateName(Restaurant restaurant); -} diff --git a/src/main/java/com/delivery/restaurant/RestaurantRepositoryMybatis.java b/src/main/java/com/delivery/restaurant/RestaurantRepositoryMybatis.java deleted file mode 100644 index 032aed42..00000000 --- a/src/main/java/com/delivery/restaurant/RestaurantRepositoryMybatis.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.delivery.restaurant; - -import org.springframework.stereotype.Repository; - -import com.delivery.restaurant.businesshour.BusinessHour; -import com.delivery.restaurant.businesshour.BusinessHourMapper; -import com.delivery.restaurant.businesshour.BusinessHourResponse; - -@Repository -public class RestaurantRepositoryMybatis implements RestaurantRepository { - - private final RestaurantMapper restaurantMapper; - private final BusinessHourMapper businessHourMapper; - - public RestaurantRepositoryMybatis(RestaurantMapper restaurantMapper, BusinessHourMapper businessHourMapper) { - this.restaurantMapper = restaurantMapper; - this.businessHourMapper = businessHourMapper; - } - - @Override - public Restaurant findRestaurantById(Long id) { - Restaurant restaurant = restaurantMapper.findRestaurantById(id); - if (restaurant == null) { - throw new IllegalArgumentException("restaurant does not exist"); - } - return restaurant; - } - - @Override - public void updateBusinessHour(Restaurant restaurant) { - businessHourMapper.deleteAllByRestaurantId(restaurant.getId()); - insertBusinessHour(restaurant); - } - - @Override - public void updateIntroduce(Restaurant restaurant) { - restaurantMapper.updateIntroduce(restaurant.getId(), restaurant.getIntroduce()); - } - - @Override - public void updatePhone(Restaurant restaurant) { - restaurantMapper.updatePhone(restaurant.getId(), restaurant.getPhone()); - } - - @Override - public void updateDeliveryAreaGuide(Restaurant restaurant) { - restaurantMapper.updateDeliveryAreaGuide(restaurant.getId(), restaurant.getDeliveryAreaGuide()); - } - - @Override - public void updateName(Restaurant restaurant) { - restaurantMapper.updateName(restaurant.getId(), restaurant.getName()); - } - - private BusinessHourResponse insertBusinessHour(Restaurant restaurant) { - BusinessHourResponse bhResponse = restaurant.getBusinessHour(); - for (BusinessHour bh : bhResponse.getBusinessHours()) { - businessHourMapper.insert( - new BusinessHour( - restaurant.getId(), - bh.getOpen(), - bh.getClose(), - bh.getDayOfWeek()) - ); - } - return bhResponse; - } - -} diff --git a/src/main/java/com/delivery/restaurant/RestaurantUpdateService.java b/src/main/java/com/delivery/restaurant/RestaurantUpdateService.java deleted file mode 100644 index c34d3bf3..00000000 --- a/src/main/java/com/delivery/restaurant/RestaurantUpdateService.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.delivery.restaurant; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.delivery.restaurant.businesshour.BusinessHourConditions; -import com.delivery.restaurant.businesshour.BusinessHourResponse; -import com.delivery.restaurant.businesshour.UpdateBusinessHoursDto; - -@Service -public class RestaurantUpdateService { - - private final RestaurantRepository restaurantRepository; - - public RestaurantUpdateService(RestaurantRepository restaurantRepository) { - this.restaurantRepository = restaurantRepository; - } - - @Transactional - public BusinessHourResponse updateBusinessHour(Long id, UpdateBusinessHoursDto dto) { - Restaurant restaurant = restaurantRepository.findRestaurantById(id); - restaurant.updateBusinessHour( - BusinessHourConditions.makeBusinessHoursBy(restaurant.getId(), dto)); - restaurantRepository.updateBusinessHour(restaurant); - return restaurant.getBusinessHour(); - } - - public void editIntroduce(Long id, String introduce) { - Restaurant restaurant = restaurantRepository.findRestaurantById(id); - restaurant.editIntroduce(introduce); - restaurantRepository.updateIntroduce(restaurant); - } - - public void editPhoneNumber(Long id, String phone) { - Restaurant restaurant = restaurantRepository.findRestaurantById(id); - restaurant.editPhoneNumber(phone); - restaurantRepository.updatePhone(restaurant); - } - - public void editDeliveryAreaGuide(Long id, String guide) { - Restaurant restaurant = restaurantRepository.findRestaurantById(id); - restaurant.editDeliveryAreaGuide(guide); - restaurantRepository.updateDeliveryAreaGuide(restaurant); - } - - public void rename(Long id, String name) { - Restaurant restaurant = restaurantRepository.findRestaurantById(id); - restaurant.rename(name); - restaurantRepository.updateName(restaurant); - } -} diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourCondition.java b/src/main/java/com/delivery/restaurant/businesshour/BusinessHourCondition.java deleted file mode 100644 index cd35e6ee..00000000 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourCondition.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.delivery.restaurant.businesshour; - -import com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.BusinessHourType; - -public interface BusinessHourCondition { - - boolean isSatisfied(BusinessHourType type, BusinessHourRequestParams params); - - BusinessHourPolicy returnBusinessHourPolicy(Long restId, BusinessHourRequestParams params); -} diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHour.java b/src/main/java/com/delivery/shop/businesshour/BusinessHour.java similarity index 88% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHour.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHour.java index e340938b..8c5d4e0d 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHour.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHour.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import java.time.DayOfWeek; @@ -7,7 +7,7 @@ public class BusinessHour { - private Long restId; + private Long shopId; private LocalTime open; private LocalTime close; private DayOfWeek dayOfWeek; @@ -21,8 +21,8 @@ public BusinessHour(DayOfWeek dayOfWeek, LocalTime open, LocalTime close) { this.close = close; } - public BusinessHour(Long restId, LocalTime open, LocalTime close, DayOfWeek dayOfWeek) { - this.restId = restId; + public BusinessHour(Long shopId, LocalTime open, LocalTime close, DayOfWeek dayOfWeek) { + this.shopId = shopId; this.open = open; this.close = close; this.dayOfWeek = dayOfWeek; diff --git a/src/main/java/com/delivery/shop/businesshour/BusinessHourCondition.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourCondition.java new file mode 100644 index 00000000..f23521aa --- /dev/null +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourCondition.java @@ -0,0 +1,10 @@ +package com.delivery.shop.businesshour; + +import com.delivery.shop.businesshour.UpdateBusinessHoursDto.BusinessHourType; + +public interface BusinessHourCondition { + + boolean isSatisfied(BusinessHourType type, BusinessHourRequestParams params); + + BusinessHourPolicy returnBusinessHourPolicy(Long shopId, BusinessHourRequestParams params); +} diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourConditions.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourConditions.java similarity index 71% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourConditions.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourConditions.java index 4453ad9a..96536737 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourConditions.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourConditions.java @@ -1,6 +1,6 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; -import static com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.*; +import static com.delivery.shop.businesshour.UpdateBusinessHoursDto.*; import java.util.ArrayList; import java.util.List; @@ -14,12 +14,12 @@ public class BusinessHourConditions { conditions.add(new WeekdayWeekendBusinessHourCondition()); } - public static BusinessHourPolicy makeBusinessHoursBy(Long restId, UpdateBusinessHoursDto dto) { + public static BusinessHourPolicy makeBusinessHoursBy(Long shopId, UpdateBusinessHoursDto dto) { BusinessHourType type = dto.getBusinessHourType(); BusinessHourRequestParams params = dto.getBusinessHours(); for (BusinessHourCondition condition : conditions) { if (condition.isSatisfied(type, params)) { - return condition.returnBusinessHourPolicy(restId, params); + return condition.returnBusinessHourPolicy(shopId, params); } } throw new IllegalArgumentException("wrong values for business hour"); diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourMapper.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourMapper.java similarity index 61% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourMapper.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourMapper.java index 2495602e..e4e03b9c 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourMapper.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourMapper.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import org.apache.ibatis.annotations.Mapper; @@ -7,6 +7,6 @@ public interface BusinessHourMapper { void insert(BusinessHour param); - void deleteAllByRestaurantId(Long restId); + void deleteAllByShopId(Long shopId); } diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourPolicy.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourPolicy.java similarity index 94% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourPolicy.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourPolicy.java index c525aa59..b9a91b9f 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourPolicy.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourPolicy.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import java.time.DayOfWeek; import java.util.ArrayList; diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParam.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParam.java similarity index 86% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParam.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParam.java index d17b11b3..fa00cdd3 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParam.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParam.java @@ -1,11 +1,9 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import java.time.DayOfWeek; import java.time.LocalTime; -import com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.DayType; - public class BusinessHourRequestParam { private LocalTime open; diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParams.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParams.java similarity index 88% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParams.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParams.java index c81f041d..adba4450 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourRequestParams.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourRequestParams.java @@ -1,9 +1,8 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; -import static com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.*; +import static com.delivery.shop.businesshour.UpdateBusinessHoursDto.*; import java.util.Collections; -import java.util.List; import java.util.Map; public class BusinessHourRequestParams { diff --git a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourResponse.java b/src/main/java/com/delivery/shop/businesshour/BusinessHourResponse.java similarity index 90% rename from src/main/java/com/delivery/restaurant/businesshour/BusinessHourResponse.java rename to src/main/java/com/delivery/shop/businesshour/BusinessHourResponse.java index 44eba05a..17837306 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/BusinessHourResponse.java +++ b/src/main/java/com/delivery/shop/businesshour/BusinessHourResponse.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import java.util.List; diff --git a/src/main/java/com/delivery/restaurant/businesshour/EverydayBusinessHourCondition.java b/src/main/java/com/delivery/shop/businesshour/EverydayBusinessHourCondition.java similarity index 78% rename from src/main/java/com/delivery/restaurant/businesshour/EverydayBusinessHourCondition.java rename to src/main/java/com/delivery/shop/businesshour/EverydayBusinessHourCondition.java index 4f499a0d..abea3ebf 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/EverydayBusinessHourCondition.java +++ b/src/main/java/com/delivery/shop/businesshour/EverydayBusinessHourCondition.java @@ -1,6 +1,6 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; -import static com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.*; +import static com.delivery.shop.businesshour.UpdateBusinessHoursDto.*; import java.time.DayOfWeek; @@ -14,7 +14,7 @@ public boolean isSatisfied(BusinessHourType type, BusinessHourRequestParams para } @Override - public BusinessHourPolicy returnBusinessHourPolicy(Long restId, BusinessHourRequestParams params) { + public BusinessHourPolicy returnBusinessHourPolicy(Long shopId, BusinessHourRequestParams params) { BusinessHourPolicy policy = new BusinessHourPolicy(); BusinessHourRequestParam bh = params.getParamByDayType(DayType.EVERYDAY); for (DayOfWeek day : DayOfWeek.values()) { diff --git a/src/main/java/com/delivery/restaurant/businesshour/UpdateBusinessHoursDto.java b/src/main/java/com/delivery/shop/businesshour/UpdateBusinessHoursDto.java similarity index 92% rename from src/main/java/com/delivery/restaurant/businesshour/UpdateBusinessHoursDto.java rename to src/main/java/com/delivery/shop/businesshour/UpdateBusinessHoursDto.java index a5191e67..c84ff35e 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/UpdateBusinessHoursDto.java +++ b/src/main/java/com/delivery/shop/businesshour/UpdateBusinessHoursDto.java @@ -1,7 +1,6 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; public class UpdateBusinessHoursDto { diff --git a/src/main/java/com/delivery/restaurant/businesshour/WeekdayWeekendBusinessHourCondition.java b/src/main/java/com/delivery/shop/businesshour/WeekdayWeekendBusinessHourCondition.java similarity index 85% rename from src/main/java/com/delivery/restaurant/businesshour/WeekdayWeekendBusinessHourCondition.java rename to src/main/java/com/delivery/shop/businesshour/WeekdayWeekendBusinessHourCondition.java index 297b7e39..7e1670fe 100644 --- a/src/main/java/com/delivery/restaurant/businesshour/WeekdayWeekendBusinessHourCondition.java +++ b/src/main/java/com/delivery/shop/businesshour/WeekdayWeekendBusinessHourCondition.java @@ -1,6 +1,6 @@ -package com.delivery.restaurant.businesshour; +package com.delivery.shop.businesshour; -import static com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.*; +import static com.delivery.shop.businesshour.UpdateBusinessHoursDto.*; import static java.time.DayOfWeek.*; import java.time.DayOfWeek; @@ -16,7 +16,7 @@ public boolean isSatisfied(BusinessHourType type, BusinessHourRequestParams para } @Override - public BusinessHourPolicy returnBusinessHourPolicy(Long restId, BusinessHourRequestParams params) { + public BusinessHourPolicy returnBusinessHourPolicy(Long shopId, BusinessHourRequestParams params) { BusinessHourPolicy policy = new BusinessHourPolicy(); BusinessHourRequestParam weekday = params.getParamByDayType(DayType.WEEKDAY); BusinessHourRequestParam sat = params.getParamByDayType(DayType.SATURDAY); diff --git a/src/main/java/com/delivery/restaurant/menu/Menu.java b/src/main/java/com/delivery/shop/menu/Menu.java similarity index 92% rename from src/main/java/com/delivery/restaurant/menu/Menu.java rename to src/main/java/com/delivery/shop/menu/Menu.java index de2df4b4..bd84bc4a 100644 --- a/src/main/java/com/delivery/restaurant/menu/Menu.java +++ b/src/main/java/com/delivery/shop/menu/Menu.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.menu; +package com.delivery.shop.menu; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/delivery/restaurant/menugroup/MenuGroup.java b/src/main/java/com/delivery/shop/menu/MenuGroup.java similarity index 74% rename from src/main/java/com/delivery/restaurant/menugroup/MenuGroup.java rename to src/main/java/com/delivery/shop/menu/MenuGroup.java index eb2560c9..f44ab722 100644 --- a/src/main/java/com/delivery/restaurant/menugroup/MenuGroup.java +++ b/src/main/java/com/delivery/shop/menu/MenuGroup.java @@ -1,22 +1,22 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menu; import java.util.List; -import com.delivery.restaurant.menu.Menu; +import com.delivery.shop.menu.Menu; public class MenuGroup { private Long id; private String groupName; private String content; - private Long restaurantId; + private Long shopId; private List menuList; - public MenuGroup(Long id, String groupName, String content, Long restaurantId, List menuList) { + public MenuGroup(Long id, String groupName, String content, Long shopId, List menuList) { this.id = id; this.groupName = groupName; this.content = content; - this.restaurantId = restaurantId; + this.shopId = shopId; this.menuList = menuList; } @@ -33,7 +33,7 @@ public String getContent() { } public Long getShopId() { - return restaurantId; + return shopId; } public List getMenuList() { diff --git a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupController.java b/src/main/java/com/delivery/shop/menu/MenuGroupController.java similarity index 78% rename from src/main/java/com/delivery/restaurant/menugroup/MenuGroupController.java rename to src/main/java/com/delivery/shop/menu/MenuGroupController.java index f5071a63..aede9b21 100644 --- a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupController.java +++ b/src/main/java/com/delivery/shop/menu/MenuGroupController.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menu; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -19,11 +19,11 @@ public MenuGroupController(MenuGroupService service) { this.service = service; } - @PostMapping("restaurants/{restaurantId}/menuGroups") + @PostMapping("shop/{shopId}/menuGroups") public ResponseEntity registerMenuGroup(@Validated @RequestBody MenuGroupDto dto, - @PathVariable Long restaurantId) { - if (!dto.checkRestaurantId(restaurantId)) { - throw new NotFoundIdException("not found restaurantId"); + @PathVariable Long shopId) { + if (!dto.checkShopId(shopId)) { + throw new NotFoundIdException("not found shopId"); } service.registerMenuGroup(dto); return ResponseEntity.status(HttpStatus.CREATED).build(); diff --git a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupDto.java b/src/main/java/com/delivery/shop/menu/MenuGroupDto.java similarity index 65% rename from src/main/java/com/delivery/restaurant/menugroup/MenuGroupDto.java rename to src/main/java/com/delivery/shop/menu/MenuGroupDto.java index 95dbe421..a1b3b0aa 100644 --- a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupDto.java +++ b/src/main/java/com/delivery/shop/menu/MenuGroupDto.java @@ -1,17 +1,17 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menu; import java.util.List; import javax.validation.constraints.NotNull; -import com.delivery.restaurant.menu.Menu; +import com.delivery.shop.menu.Menu; public class MenuGroupDto { private Long id; @NotNull - private Long restaurantId; + private Long shopId; @NotNull private String name; @@ -20,9 +20,9 @@ public class MenuGroupDto { private List menus; - public MenuGroupDto(Long id, Long restaurantId, String name, String content, List menus) { + public MenuGroupDto(Long id, Long shopId, String name, String content, List menus) { this.id = id; - this.restaurantId = restaurantId; + this.shopId = shopId; this.name = name; this.content = content; this.menus = menus; @@ -39,12 +39,12 @@ public void setId(Long id) { this.id = id; } - public Long getRestaurantId() { - return restaurantId; + public Long getShopId() { + return shopId; } - public void setRestaurantId(Long restaurantId) { - this.restaurantId = restaurantId; + public void setShopId(Long shopId) { + this.shopId = shopId; } public String getName() { @@ -71,7 +71,7 @@ public void setMenus(List menus) { this.menus = menus; } - public boolean checkRestaurantId(Long id) { - return this.restaurantId == id; + public boolean checkShopId(Long id) { + return this.shopId == id; } } diff --git a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupMapper.java b/src/main/java/com/delivery/shop/menu/MenuGroupMapper.java similarity index 84% rename from src/main/java/com/delivery/restaurant/menugroup/MenuGroupMapper.java rename to src/main/java/com/delivery/shop/menu/MenuGroupMapper.java index 6ce0e8b6..3c47b956 100644 --- a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupMapper.java +++ b/src/main/java/com/delivery/shop/menu/MenuGroupMapper.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menu; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupService.java b/src/main/java/com/delivery/shop/menu/MenuGroupService.java similarity index 94% rename from src/main/java/com/delivery/restaurant/menugroup/MenuGroupService.java rename to src/main/java/com/delivery/shop/menu/MenuGroupService.java index b10f6c64..44711ba3 100644 --- a/src/main/java/com/delivery/restaurant/menugroup/MenuGroupService.java +++ b/src/main/java/com/delivery/shop/menu/MenuGroupService.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menu; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; diff --git a/src/main/java/com/delivery/restaurant/EditPhoneDto.java b/src/main/java/com/delivery/shop/shop/EditPhoneDto.java similarity index 94% rename from src/main/java/com/delivery/restaurant/EditPhoneDto.java rename to src/main/java/com/delivery/shop/shop/EditPhoneDto.java index b20cec02..8764e13f 100644 --- a/src/main/java/com/delivery/restaurant/EditPhoneDto.java +++ b/src/main/java/com/delivery/shop/shop/EditPhoneDto.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant; +package com.delivery.shop.shop; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; diff --git a/src/main/java/com/delivery/restaurant/EditPhoneRequest.java b/src/main/java/com/delivery/shop/shop/EditPhoneRequest.java similarity index 94% rename from src/main/java/com/delivery/restaurant/EditPhoneRequest.java rename to src/main/java/com/delivery/shop/shop/EditPhoneRequest.java index 51af7817..a468ff7a 100644 --- a/src/main/java/com/delivery/restaurant/EditPhoneRequest.java +++ b/src/main/java/com/delivery/shop/shop/EditPhoneRequest.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant; +package com.delivery.shop.shop; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; diff --git a/src/main/java/com/delivery/restaurant/Restaurant.java b/src/main/java/com/delivery/shop/shop/Shop.java similarity index 83% rename from src/main/java/com/delivery/restaurant/Restaurant.java rename to src/main/java/com/delivery/shop/shop/Shop.java index 1f63752a..57137ccc 100644 --- a/src/main/java/com/delivery/restaurant/Restaurant.java +++ b/src/main/java/com/delivery/shop/shop/Shop.java @@ -1,9 +1,9 @@ -package com.delivery.restaurant; +package com.delivery.shop.shop; -import com.delivery.restaurant.businesshour.BusinessHourPolicy; -import com.delivery.restaurant.businesshour.BusinessHourResponse; +import com.delivery.shop.businesshour.BusinessHourPolicy; +import com.delivery.shop.businesshour.BusinessHourResponse; -public class Restaurant { +public class Shop { private Long id; private String name; private BusinessHourPolicy businessHours; @@ -11,7 +11,7 @@ public class Restaurant { private String phone; private String deliveryAreaGuide; - public Restaurant() { + public Shop() { } diff --git a/src/main/java/com/delivery/restaurant/RestaurantMapper.java b/src/main/java/com/delivery/shop/shop/ShopMapper.java similarity index 71% rename from src/main/java/com/delivery/restaurant/RestaurantMapper.java rename to src/main/java/com/delivery/shop/shop/ShopMapper.java index cfda618b..f1f21874 100644 --- a/src/main/java/com/delivery/restaurant/RestaurantMapper.java +++ b/src/main/java/com/delivery/shop/shop/ShopMapper.java @@ -1,11 +1,11 @@ -package com.delivery.restaurant; +package com.delivery.shop.shop; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface RestaurantMapper { +public interface ShopMapper { - Restaurant findRestaurantById(Long id); + Shop findShopById(Long id); void updateIntroduce(Long id, String introduce); diff --git a/src/main/java/com/delivery/shop/shop/ShopRepository.java b/src/main/java/com/delivery/shop/shop/ShopRepository.java new file mode 100644 index 00000000..aaf38900 --- /dev/null +++ b/src/main/java/com/delivery/shop/shop/ShopRepository.java @@ -0,0 +1,18 @@ +package com.delivery.shop.shop; + +import org.springframework.stereotype.Repository; + +@Repository +public interface ShopRepository { + Shop findShopById(Long id); + + void updateBusinessHour(Shop shop); + + void updateIntroduce(Shop shop); + + void updatePhone(Shop shop); + + void updateDeliveryAreaGuide(Shop shop); + + void updateName(Shop shop); +} diff --git a/src/main/java/com/delivery/shop/shop/ShopRepositoryMybatis.java b/src/main/java/com/delivery/shop/shop/ShopRepositoryMybatis.java new file mode 100644 index 00000000..cad1a753 --- /dev/null +++ b/src/main/java/com/delivery/shop/shop/ShopRepositoryMybatis.java @@ -0,0 +1,69 @@ +package com.delivery.shop.shop; + +import org.springframework.stereotype.Repository; + +import com.delivery.shop.businesshour.BusinessHour; +import com.delivery.shop.businesshour.BusinessHourMapper; +import com.delivery.shop.businesshour.BusinessHourResponse; + +@Repository +public class ShopRepositoryMybatis implements ShopRepository { + + private final ShopMapper shopMapper; + private final BusinessHourMapper businessHourMapper; + + public ShopRepositoryMybatis(ShopMapper shopMapper, BusinessHourMapper businessHourMapper) { + this.shopMapper = shopMapper; + this.businessHourMapper = businessHourMapper; + } + + @Override + public Shop findShopById(Long id) { + Shop shop = shopMapper.findShopById(id); + if (shop == null) { + throw new IllegalArgumentException("shop does not exist"); + } + return shop; + } + + @Override + public void updateBusinessHour(Shop shop) { + businessHourMapper.deleteAllByShopId(shop.getId()); + insertBusinessHour(shop); + } + + @Override + public void updateIntroduce(Shop shop) { + shopMapper.updateIntroduce(shop.getId(), shop.getIntroduce()); + } + + @Override + public void updatePhone(Shop shop) { + shopMapper.updatePhone(shop.getId(), shop.getPhone()); + } + + @Override + public void updateDeliveryAreaGuide(Shop shop) { + shopMapper.updateDeliveryAreaGuide(shop.getId(), shop.getDeliveryAreaGuide()); + } + + @Override + public void updateName(Shop shop) { + shopMapper.updateName(shop.getId(), shop.getName()); + } + + private BusinessHourResponse insertBusinessHour(Shop shop) { + BusinessHourResponse bhResponse = shop.getBusinessHour(); + for (BusinessHour bh : bhResponse.getBusinessHours()) { + businessHourMapper.insert( + new BusinessHour( + shop.getId(), + bh.getOpen(), + bh.getClose(), + bh.getDayOfWeek()) + ); + } + return bhResponse; + } + +} diff --git a/src/main/java/com/delivery/restaurant/RestaurantUpdateController.java b/src/main/java/com/delivery/shop/shop/ShopUpdateController.java similarity index 84% rename from src/main/java/com/delivery/restaurant/RestaurantUpdateController.java rename to src/main/java/com/delivery/shop/shop/ShopUpdateController.java index 00452a35..fcf2a840 100644 --- a/src/main/java/com/delivery/restaurant/RestaurantUpdateController.java +++ b/src/main/java/com/delivery/shop/shop/ShopUpdateController.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant; +package com.delivery.shop.shop; import javax.validation.Valid; @@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.delivery.restaurant.businesshour.UpdateBusinessHoursDto; +import com.delivery.shop.businesshour.UpdateBusinessHoursDto; @RestController -@RequestMapping("/restaurants") -public class RestaurantUpdateController { +@RequestMapping("/shops") +public class ShopUpdateController { - private RestaurantUpdateService updateService; + private ShopUpdateService updateService; - public RestaurantUpdateController(RestaurantUpdateService updateService) { + public ShopUpdateController(ShopUpdateService updateService) { this.updateService = updateService; } diff --git a/src/main/java/com/delivery/shop/shop/ShopUpdateService.java b/src/main/java/com/delivery/shop/shop/ShopUpdateService.java new file mode 100644 index 00000000..135b0dfc --- /dev/null +++ b/src/main/java/com/delivery/shop/shop/ShopUpdateService.java @@ -0,0 +1,51 @@ +package com.delivery.shop.shop; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.delivery.shop.businesshour.BusinessHourConditions; +import com.delivery.shop.businesshour.BusinessHourResponse; +import com.delivery.shop.businesshour.UpdateBusinessHoursDto; + +@Service +public class ShopUpdateService { + + private final ShopRepository shopRepository; + + public ShopUpdateService(ShopRepository shopRepository) { + this.shopRepository = shopRepository; + } + + @Transactional + public BusinessHourResponse updateBusinessHour(Long id, UpdateBusinessHoursDto dto) { + Shop shop = shopRepository.findShopById(id); + shop.updateBusinessHour( + BusinessHourConditions.makeBusinessHoursBy(shop.getId(), dto)); + shopRepository.updateBusinessHour(shop); + return shop.getBusinessHour(); + } + + public void editIntroduce(Long id, String introduce) { + Shop shop = shopRepository.findShopById(id); + shop.editIntroduce(introduce); + shopRepository.updateIntroduce(shop); + } + + public void editPhoneNumber(Long id, String phone) { + Shop shop = shopRepository.findShopById(id); + shop.editPhoneNumber(phone); + shopRepository.updatePhone(shop); + } + + public void editDeliveryAreaGuide(Long id, String guide) { + Shop shop = shopRepository.findShopById(id); + shop.editDeliveryAreaGuide(guide); + shopRepository.updateDeliveryAreaGuide(shop); + } + + public void rename(Long id, String name) { + Shop shop = shopRepository.findShopById(id); + shop.rename(name); + shopRepository.updateName(shop); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4bb1e7f8..fde50760 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,8 +13,7 @@ spring: mybatis: mapper-locations: mybatis/mapper/*.xml type-aliases-package: - com.delivery.restaurant, - com.delivery.restaurant.businesshour, - com.delivery.restaurant.businesshour, + com.delivery.shop, + com.delivery.shop.businesshour, com.delivery.utility, org.apache.ibatis.type diff --git a/src/main/resources/db/migration/V202106021837__init.sql b/src/main/resources/db/migration/V202106021837__init.sql deleted file mode 100644 index fa46eac0..00000000 --- a/src/main/resources/db/migration/V202106021837__init.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE RESTAURANTS -( - ID INT AUTO_INCREMENT, - NAME VARCHAR(100) NOT NULL, - PRIMARY KEY (ID) -); - -CREATE TABLE BUSINESS_HOURS -( - ID INT AUTO_INCREMENT, - REST_ID INT, - OPEN TIME, - CLOSE TIME, - DAY_TYPE VARCHAR(50), - BUSINESS_HOUR_TYPE varchar(50), - PRIMARY KEY (ID), - FOREIGN KEY (REST_ID) REFERENCES RESTAURANTS(ID) -); - -CREATE TABLE MENU -( - ID INT AUTO_INCREMENT, - NAME VARCHAR(100) NOT NULL, - PRICE INT, - PRIMARY KEY (ID) -); - -CREATE TABLE MENU_GROUP -( - ID INT AUTO_INCREMENT, - RESTAURANT_ID INT NOT NULL, - NAME VARCHAR(100) NOT NULL, - CONTENT VARCHAR(100), - PRIMARY KEY (ID), - FOREIGN KEY (RESTAURANT_ID) REFERENCES RESTAURANTS(ID) -); diff --git a/src/main/resources/db/migration/V202106022120__editRestaurant_businessHour.sql b/src/main/resources/db/migration/V202106022120__editRestaurant_businessHour.sql deleted file mode 100644 index 27729bd7..00000000 --- a/src/main/resources/db/migration/V202106022120__editRestaurant_businessHour.sql +++ /dev/null @@ -1,18 +0,0 @@ -RENAME TABLE RESTAURANTS TO RESTAURANT; - -ALTER TABLE RESTAURANT ADD COLUMN INTRODUCE varchar(500); -ALTER TABLE RESTAURANT ADD COLUMN phone varchar(14); -ALTER TABLE RESTAURANT ADD COLUMN DELIVERY_AREA_GUIDE varchar(500); - -CREATE TABLE BUSINESS_HOUR -( - ID INT AUTO_INCREMENT, - REST_ID INT, - OPEN TIME, - CLOSE TIME, - DAY_OF_WEEK VARCHAR(50), - PRIMARY KEY (ID), - FOREIGN KEY (REST_ID) REFERENCES RESTAURANT (ID) -); - -INSERT INTO RESTAURANT (NAME) VALUES ('BBQ 효자동점'); diff --git a/src/main/resources/db/migration/V202106071728__init.sql b/src/main/resources/db/migration/V202106071728__init.sql new file mode 100644 index 00000000..392b4195 --- /dev/null +++ b/src/main/resources/db/migration/V202106071728__init.sql @@ -0,0 +1,40 @@ +CREATE TABLE SHOP +( + ID INT AUTO_INCREMENT, + NAME VARCHAR(100) NOT NULL, + INTRODUCE varchar(500), + phone varchar(14), + DELIVERY_AREA_GUIDE varchar(500), + PRIMARY KEY (ID) +); + +CREATE TABLE BUSINESS_HOUR +( + ID INT AUTO_INCREMENT, + SHOP_ID INT, + OPEN TIME, + CLOSE TIME, + DAY_OF_WEEK VARCHAR(50), + PRIMARY KEY (ID), + FOREIGN KEY (SHOP_ID) REFERENCES SHOP (ID) +); + +CREATE TABLE MENU +( + ID INT AUTO_INCREMENT, + NAME VARCHAR(100) NOT NULL, + PRICE INT, + PRIMARY KEY (ID) +); + +CREATE TABLE MENU_GROUP +( + ID INT AUTO_INCREMENT, + RESTAURANT_ID INT NOT NULL, + NAME VARCHAR(100) NOT NULL, + CONTENT VARCHAR(100), + PRIMARY KEY (ID), + FOREIGN KEY (RESTAURANT_ID) REFERENCES SHOP(ID) +); + +INSERT INTO SHOP (NAME) VALUES ('BBQ 효자동점'); diff --git a/src/main/resources/mybatis/mapper/BusinessHourMapper.xml b/src/main/resources/mybatis/mapper/BusinessHourMapper.xml index b4732e67..59c536f3 100644 --- a/src/main/resources/mybatis/mapper/BusinessHourMapper.xml +++ b/src/main/resources/mybatis/mapper/BusinessHourMapper.xml @@ -3,14 +3,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - INSERT INTO BUSINESS_HOUR (REST_ID, OPEN, CLOSE, DAY_OF_WEEK) - VALUES (#{restId}, #{open}, #{close}, #{dayOfWeek}) + INSERT INTO BUSINESS_HOUR (SHOP_ID, OPEN, CLOSE, DAY_OF_WEEK) + VALUES (#{shopId}, #{open}, #{close}, #{dayOfWeek}) - - DELETE FROM BUSINESS_HOUR WHERE REST_ID=#{restId} + + DELETE FROM BUSINESS_HOUR WHERE SHOP_ID=#{shopId} diff --git a/src/main/resources/mybatis/mapper/MenuGroupMapper.xml b/src/main/resources/mybatis/mapper/MenuGroupMapper.xml index b7437de5..36fe2591 100644 --- a/src/main/resources/mybatis/mapper/MenuGroupMapper.xml +++ b/src/main/resources/mybatis/mapper/MenuGroupMapper.xml @@ -1,10 +1,10 @@ - + - - INSERT INTO MENU_GROUP(RESTAURANT_ID, NAME, CONTENT) - VALUES (#{restaurantId}, #{name}, #{content}) + + INSERT INTO MENU_GROUP(SHOP_ID, NAME, CONTENT) + VALUES (#{shopId}, #{name}, #{content}) + - UPDATE RESTAURANT + UPDATE SHOP SET INTRODUCE = #{introduce} WHERE id = #{id} - UPDATE RESTAURANT + UPDATE SHOP SET PHONE = #{phone} WHERE id = #{id} - UPDATE RESTAURANT + UPDATE SHOP SET DELIVERY_AREA_GUIDE = #{guide} WHERE id = #{id} - UPDATE RESTAURANT + UPDATE SHOP SET DELIVERY_AREA_GUIDE = #{name} WHERE id = #{id} diff --git a/src/test/java/com/delivery/restaurant/BusinessHourPolicyConditionsTest.java b/src/test/java/com/delivery/shop/BusinessHourPolicyConditionsTest.java similarity index 87% rename from src/test/java/com/delivery/restaurant/BusinessHourPolicyConditionsTest.java rename to src/test/java/com/delivery/shop/BusinessHourPolicyConditionsTest.java index 0692ab75..45725569 100644 --- a/src/test/java/com/delivery/restaurant/BusinessHourPolicyConditionsTest.java +++ b/src/test/java/com/delivery/shop/BusinessHourPolicyConditionsTest.java @@ -1,6 +1,6 @@ -package com.delivery.restaurant; +package com.delivery.shop; -import static com.delivery.restaurant.businesshour.UpdateBusinessHoursDto.*; +import static com.delivery.shop.businesshour.UpdateBusinessHoursDto.*; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; @@ -11,14 +11,12 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import com.delivery.restaurant.businesshour.BusinessHour; -import com.delivery.restaurant.businesshour.BusinessHourConditions; -import com.delivery.restaurant.businesshour.BusinessHourPolicy; -import com.delivery.restaurant.businesshour.BusinessHourRequestParam; -import com.delivery.restaurant.businesshour.BusinessHourRequestParams; -import com.delivery.restaurant.businesshour.UpdateBusinessHoursDto; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.delivery.shop.businesshour.BusinessHour; +import com.delivery.shop.businesshour.BusinessHourConditions; +import com.delivery.shop.businesshour.BusinessHourPolicy; +import com.delivery.shop.businesshour.BusinessHourRequestParam; +import com.delivery.shop.businesshour.BusinessHourRequestParams; +import com.delivery.shop.businesshour.UpdateBusinessHoursDto; class BusinessHourPolicyConditionsTest { diff --git a/src/test/java/com/delivery/restaurant/menugroup/MenuGroupServiceTest.java b/src/test/java/com/delivery/shop/menugroup/MenuGroupServiceTest.java similarity index 84% rename from src/test/java/com/delivery/restaurant/menugroup/MenuGroupServiceTest.java rename to src/test/java/com/delivery/shop/menugroup/MenuGroupServiceTest.java index b35f7c6c..9eb0bc6f 100644 --- a/src/test/java/com/delivery/restaurant/menugroup/MenuGroupServiceTest.java +++ b/src/test/java/com/delivery/shop/menugroup/MenuGroupServiceTest.java @@ -1,4 +1,4 @@ -package com.delivery.restaurant.menugroup; +package com.delivery.shop.menugroup; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -8,6 +8,10 @@ import org.mockito.Mock; import org.springframework.boot.test.context.SpringBootTest; +import com.delivery.shop.menu.MenuGroupDto; +import com.delivery.shop.menu.MenuGroupMapper; +import com.delivery.shop.menu.MenuGroupService; + @SpringBootTest class MenuGroupServiceTest { @@ -23,7 +27,7 @@ public void registerMenuGroupTest() { MenuGroupDto menuGroup = new MenuGroupDto(); menuGroup.setName("대표 메뉴"); menuGroup.setContent("10000원"); - menuGroup.setRestaurantId(1L); + menuGroup.setShopId(1L); given(menuGroupMapper.saveMenuGroup(menuGroup)) .willReturn(1); service.registerMenuGroup(menuGroup);