Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
#50 package 구조 통합 (#52)
Browse files Browse the repository at this point in the history
* style: MenuGroup(restaurant -> shop) 네이밍 수정

* style: rename restaurant -> shop

* style: 빼먹은 부분 수정

* shop -> shop-shop

Co-authored-by: soongjamm <kimstz0303@gmail.com>
  • Loading branch information
lyh7712 and soongjamm authored Jun 7, 2021
1 parent a09dd51 commit 8225c36
Show file tree
Hide file tree
Showing 40 changed files with 296 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/delivery/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,7 +19,7 @@ public class WebConfig {
@Profile("dev")
static class DevConfig {
@Autowired
private RestaurantMapper restaurantMapper;
private ShopMapper shopMapper;
@Autowired
private BusinessHourMapper businessHourMapper;

Expand All @@ -29,8 +29,8 @@ public UserRepository userRepository() {
}

@Bean
public RestaurantRepository restaurantRepository() {
return new RestaurantRepositoryMybatis(restaurantMapper, businessHourMapper);
public ShopRepository shopRepository() {
return new ShopRepositoryMybatis(shopMapper, businessHourMapper);
}
}

Expand Down
18 changes: 0 additions & 18 deletions src/main/java/com/delivery/restaurant/RestaurantRepository.java

This file was deleted.

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/java/com/delivery/restaurant/RestaurantUpdateService.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.delivery.restaurant.businesshour;
package com.delivery.shop.businesshour;


import java.time.DayOfWeek;
Expand All @@ -7,7 +7,7 @@

public class BusinessHour {

private Long restId;
private Long shopId;
private LocalTime open;
private LocalTime close;
private DayOfWeek dayOfWeek;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.delivery.restaurant.businesshour;
package com.delivery.shop.businesshour;

import org.apache.ibatis.annotations.Mapper;

Expand All @@ -7,6 +7,6 @@ public interface BusinessHourMapper {

void insert(BusinessHour param);

void deleteAllByRestaurantId(Long restId);
void deleteAllByShopId(Long shopId);

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.delivery.restaurant.businesshour;
package com.delivery.shop.businesshour;

import java.time.DayOfWeek;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.delivery.restaurant.businesshour;
package com.delivery.shop.businesshour;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.delivery.restaurant.menu;
package com.delivery.shop.menu;

import javax.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Menu> menuList;

public MenuGroup(Long id, String groupName, String content, Long restaurantId, List<Menu> menuList) {
public MenuGroup(Long id, String groupName, String content, Long shopId, List<Menu> menuList) {
this.id = id;
this.groupName = groupName;
this.content = content;
this.restaurantId = restaurantId;
this.shopId = shopId;
this.menuList = menuList;
}

Expand All @@ -33,7 +33,7 @@ public String getContent() {
}

public Long getShopId() {
return restaurantId;
return shopId;
}

public List<Menu> getMenuList() {
Expand Down
Loading

0 comments on commit 8225c36

Please sign in to comment.