diff --git a/src/main/java/com/delfood/config/RedisConfig.java b/src/main/java/com/delfood/config/RedisConfig.java index c5c80c8..daaffee 100644 --- a/src/main/java/com/delfood/config/RedisConfig.java +++ b/src/main/java/com/delfood/config/RedisConfig.java @@ -74,6 +74,8 @@ public ObjectMapper objectMapper() { @Bean public RedisConnectionFactory redisConnectionFactory() { RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); + redisStandaloneConfiguration.setPort(redisPort); + redisStandaloneConfiguration.setHostName(redisHost); redisStandaloneConfiguration.setPassword(redisPwd); LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration); diff --git a/src/main/java/com/delfood/controller/CartControllelr.java b/src/main/java/com/delfood/controller/CartControllelr.java index 69bdc96..1eac902 100644 --- a/src/main/java/com/delfood/controller/CartControllelr.java +++ b/src/main/java/com/delfood/controller/CartControllelr.java @@ -2,8 +2,8 @@ import com.delfood.aop.LoginCheck; import com.delfood.aop.LoginCheck.UserType; +import com.delfood.dto.order.item.ItemDTO; import com.delfood.aop.MemberLoginCheck; -import com.delfood.dto.ItemDTO; import com.delfood.service.CartService; import com.delfood.utils.SessionUtil; import java.util.List; diff --git a/src/main/java/com/delfood/controller/CouponController.java b/src/main/java/com/delfood/controller/CouponController.java index c36f6c0..5fc6b66 100644 --- a/src/main/java/com/delfood/controller/CouponController.java +++ b/src/main/java/com/delfood/controller/CouponController.java @@ -1,6 +1,6 @@ package com.delfood.controller; -import com.delfood.dto.CouponDTO; +import com.delfood.dto.order.coupon.CouponDTO; import com.delfood.service.CouponService; import lombok.extern.log4j.Log4j2; import java.time.LocalDateTime; diff --git a/src/main/java/com/delfood/controller/CouponIssueController.java b/src/main/java/com/delfood/controller/CouponIssueController.java index d1dcccb..92dca4c 100644 --- a/src/main/java/com/delfood/controller/CouponIssueController.java +++ b/src/main/java/com/delfood/controller/CouponIssueController.java @@ -2,8 +2,8 @@ import com.delfood.aop.LoginCheck; import com.delfood.aop.LoginCheck.UserType; +import com.delfood.dto.order.coupon.CouponIssueDTO; import com.delfood.aop.MemberLoginCheck; -import com.delfood.dto.CouponIssueDTO; import com.delfood.service.CouponIssueService; import com.delfood.utils.SessionUtil; import java.util.List; diff --git a/src/main/java/com/delfood/controller/LocationController.java b/src/main/java/com/delfood/controller/LocationController.java index d9657bb..9ec0a75 100644 --- a/src/main/java/com/delfood/controller/LocationController.java +++ b/src/main/java/com/delfood/controller/LocationController.java @@ -3,8 +3,8 @@ import com.delfood.aop.OwnerShopCheck; import com.delfood.controller.reqeust.GetAddressByZipRequest; import com.delfood.controller.reqeust.GetAddressesByRoadRequest; -import com.delfood.dto.AddressDTO; -import com.delfood.dto.DeliveryLocationDTO; +import com.delfood.dto.address.AddressDTO; +import com.delfood.dto.address.DeliveryLocationDTO; import com.delfood.service.AddressService; import com.delfood.service.ShopService; import java.util.List; diff --git a/src/main/java/com/delfood/controller/MemberController.java b/src/main/java/com/delfood/controller/MemberController.java index 82935ec..e69a486 100644 --- a/src/main/java/com/delfood/controller/MemberController.java +++ b/src/main/java/com/delfood/controller/MemberController.java @@ -2,8 +2,8 @@ import com.delfood.aop.LoginCheck; import com.delfood.aop.LoginCheck.UserType; +import com.delfood.dto.member.MemberDTO; import com.delfood.aop.MemberLoginCheck; -import com.delfood.dto.MemberDTO; import com.delfood.error.exception.DuplicateIdException; import com.delfood.service.MemberService; import com.delfood.service.PushService; diff --git a/src/main/java/com/delfood/controller/MenuController.java b/src/main/java/com/delfood/controller/MenuController.java index 56acc6b..2fc690a 100644 --- a/src/main/java/com/delfood/controller/MenuController.java +++ b/src/main/java/com/delfood/controller/MenuController.java @@ -1,7 +1,7 @@ package com.delfood.controller; -import com.delfood.dto.MenuDTO; -import com.delfood.dto.OptionDTO; +import com.delfood.dto.menu.MenuDTO; +import com.delfood.dto.menu.OptionDTO; import com.delfood.service.MenuService; import com.delfood.service.OptionService; import java.util.List; diff --git a/src/main/java/com/delfood/controller/MenuGroupController.java b/src/main/java/com/delfood/controller/MenuGroupController.java index 8f05a82..0b317c2 100644 --- a/src/main/java/com/delfood/controller/MenuGroupController.java +++ b/src/main/java/com/delfood/controller/MenuGroupController.java @@ -1,7 +1,7 @@ package com.delfood.controller; -import com.delfood.dto.MenuGroupDTO; -import com.delfood.dto.ShopDTO; +import com.delfood.dto.menu.MenuGroupDTO; +import com.delfood.dto.shop.ShopDTO; import com.delfood.service.MenuGroupService; import com.delfood.service.ShopService; import com.delfood.utils.SessionUtil; diff --git a/src/main/java/com/delfood/controller/OrderController.java b/src/main/java/com/delfood/controller/OrderController.java index 2720bfe..262bb4b 100644 --- a/src/main/java/com/delfood/controller/OrderController.java +++ b/src/main/java/com/delfood/controller/OrderController.java @@ -5,12 +5,12 @@ import com.delfood.aop.MemberLoginCheck; import com.delfood.aop.OwnerLoginCheck; import com.delfood.controller.response.OrderResponse; -import com.delfood.dto.ItemsBillDTO; -import com.delfood.dto.OrderDTO; -import com.delfood.dto.OrderItemDTO; +import com.delfood.dto.order.OrderDTO; +import com.delfood.dto.order.bill.ItemsBillDTO; +import com.delfood.dto.order.bill.OrderBillDTO; +import com.delfood.dto.order.item.OrderItemDTO; import com.delfood.error.exception.coupon.IssuedCouponExistException; import com.delfood.error.exception.order.TotalPriceMismatchException; -import com.delfood.dto.OrderBillDTO; import com.delfood.service.CouponIssueService; import com.delfood.service.OrderService; import com.delfood.service.PushService; diff --git a/src/main/java/com/delfood/controller/OwnerController.java b/src/main/java/com/delfood/controller/OwnerController.java index fec58da..5eadcdf 100644 --- a/src/main/java/com/delfood/controller/OwnerController.java +++ b/src/main/java/com/delfood/controller/OwnerController.java @@ -2,10 +2,10 @@ import com.delfood.aop.LoginCheck; import com.delfood.aop.LoginCheck.UserType; +import com.delfood.dto.owner.OwnerDTO; +import com.delfood.dto.owner.OwnerDTO.Status; import com.delfood.aop.MemberLoginCheck; import com.delfood.aop.OwnerLoginCheck; -import com.delfood.dto.OwnerDTO; -import com.delfood.dto.OwnerDTO.Status; import com.delfood.error.exception.DuplicateIdException; import com.delfood.service.OwnerService; import com.delfood.service.PushService; diff --git a/src/main/java/com/delfood/controller/ShopController.java b/src/main/java/com/delfood/controller/ShopController.java index aad5125..6f0167a 100644 --- a/src/main/java/com/delfood/controller/ShopController.java +++ b/src/main/java/com/delfood/controller/ShopController.java @@ -19,11 +19,11 @@ import com.delfood.aop.OwnerLoginCheck; import com.delfood.aop.OwnerShopCheck; import com.delfood.aop.LoginCheck.UserType; -import com.delfood.dto.AddressDTO; -import com.delfood.dto.DeliveryLocationDTO; -import com.delfood.dto.OwnerDTO; -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ShopUpdateDTO; +import com.delfood.dto.address.AddressDTO; +import com.delfood.dto.address.DeliveryLocationDTO; +import com.delfood.dto.owner.OwnerDTO; +import com.delfood.dto.shop.ShopDTO; +import com.delfood.dto.shop.ShopUpdateDTO; import com.delfood.service.ShopService; import com.delfood.utils.SessionUtil; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/delfood/controller/ShopSearchController.java b/src/main/java/com/delfood/controller/ShopSearchController.java index f76ade3..5b8badc 100644 --- a/src/main/java/com/delfood/controller/ShopSearchController.java +++ b/src/main/java/com/delfood/controller/ShopSearchController.java @@ -3,8 +3,8 @@ import com.delfood.aop.LoginCheck; import com.delfood.aop.LoginCheck.UserType; import com.delfood.aop.MemberLoginCheck; -import com.delfood.dto.ShopCategoryDTO; -import com.delfood.dto.ShopDTO; +import com.delfood.dto.shop.ShopCategoryDTO; +import com.delfood.dto.shop.ShopDTO; import com.delfood.service.MemberService; import com.delfood.service.ShopSearchService; import com.delfood.service.ShopService; diff --git a/src/main/java/com/delfood/controller/response/OrderResponse.java b/src/main/java/com/delfood/controller/response/OrderResponse.java index 7acfd11..29e5749 100644 --- a/src/main/java/com/delfood/controller/response/OrderResponse.java +++ b/src/main/java/com/delfood/controller/response/OrderResponse.java @@ -1,6 +1,6 @@ package com.delfood.controller.response; -import com.delfood.dto.ItemsBillDTO; +import com.delfood.dto.order.bill.ItemsBillDTO; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/delfood/dao/CartDao.java b/src/main/java/com/delfood/dao/CartDao.java index 1a05fe0..edff82d 100644 --- a/src/main/java/com/delfood/dao/CartDao.java +++ b/src/main/java/com/delfood/dao/CartDao.java @@ -1,6 +1,6 @@ package com.delfood.dao; -import com.delfood.dto.ItemDTO; +import com.delfood.dto.order.item.ItemDTO; import com.delfood.utils.RedisKeyFactory; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; diff --git a/src/main/java/com/delfood/dao/FcmDao.java b/src/main/java/com/delfood/dao/FcmDao.java index dbf6ef9..99ac58c 100644 --- a/src/main/java/com/delfood/dao/FcmDao.java +++ b/src/main/java/com/delfood/dao/FcmDao.java @@ -1,6 +1,5 @@ package com.delfood.dao; -import com.delfood.dto.push.PushMessageForOne; import com.delfood.utils.RedisKeyFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.firebase.messaging.Message; diff --git a/src/main/java/com/delfood/dao/deliveery/DeliveryDao.java b/src/main/java/com/delfood/dao/deliveery/DeliveryDao.java index 8b2c19d..fb02dc8 100644 --- a/src/main/java/com/delfood/dao/deliveery/DeliveryDao.java +++ b/src/main/java/com/delfood/dao/deliveery/DeliveryDao.java @@ -1,9 +1,7 @@ package com.delfood.dao.deliveery; -import com.delfood.dto.OrderDTO.OrderStatus; -import com.delfood.dto.address.Position; +import com.delfood.dto.order.OrderDTO.OrderStatus; import com.delfood.dto.rider.DeliveryRiderDTO; -import lombok.NonNull; import java.util.List; public interface DeliveryDao { diff --git a/src/main/java/com/delfood/dao/deliveery/LocalMemoryDeliveryDao.java b/src/main/java/com/delfood/dao/deliveery/LocalMemoryDeliveryDao.java index ea44a50..cdc82ab 100644 --- a/src/main/java/com/delfood/dao/deliveery/LocalMemoryDeliveryDao.java +++ b/src/main/java/com/delfood/dao/deliveery/LocalMemoryDeliveryDao.java @@ -1,34 +1,29 @@ package com.delfood.dao.deliveery; -import com.delfood.dto.OrderDTO.OrderStatus; -import com.delfood.dto.address.Position; +import com.delfood.dto.order.OrderDTO.OrderStatus; import com.delfood.dto.rider.DeliveryRiderDTO; import com.delfood.service.OrderService; -import lombok.extern.log4j.Log4j2; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; -import java.util.Comparator; import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.annotation.concurrent.ThreadSafe; - +import lombok.extern.log4j.Log4j2; +import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; -@Repository("multiThreadDeliveryDao") +@Repository("localMemoryDeliveryDao") @ThreadSafe @Log4j2 public class LocalMemoryDeliveryDao implements DeliveryDao{ private ConcurrentHashMap riders; private ConcurrentHashMap orders; - @Value("${rider.expire}") + @Value("${expire.fcm.rider}") private Long expireTime; @Autowired diff --git a/src/main/java/com/delfood/dao/deliveery/RedisDeliveryDao.java b/src/main/java/com/delfood/dao/deliveery/RedisDeliveryDao.java new file mode 100644 index 0000000..56804f0 --- /dev/null +++ b/src/main/java/com/delfood/dao/deliveery/RedisDeliveryDao.java @@ -0,0 +1,139 @@ +package com.delfood.dao.deliveery; + +import com.delfood.dto.order.OrderDTO.OrderStatus; +import com.delfood.dto.rider.DeliveryRiderDTO; +import com.delfood.service.OrderService; +import com.delfood.utils.RedisKeyFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Repository; + +@Log4j2 +@Repository("redisDeliveryDao") +public class RedisDeliveryDao implements DeliveryDao { + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private ObjectMapper objectMapper; + + @Value("${expire.rider}") + public Long expireTime; + + private OrderService orderService; + + @Override + public void updateRiderInfo(DeliveryRiderDTO riderInfo) { + redisTemplate.opsForHash().put(RedisKeyFactory.DELIVERY_KEY, riderInfo.getRiderId(), riderInfo); + } + + @Override + public boolean deleteRiderInfo(String riderId) { + return redisTemplate.opsForHash().delete(RedisKeyFactory.DELIVERY_KEY, riderId) != null; + } + + @Override + public boolean hasRiderInfo(String riderId) { + return redisTemplate.opsForHash().hasKey(RedisKeyFactory.DELIVERY_KEY, riderId); + } + + /** + * 특정 시점을 기준으로 일정시간 자신의 위치를 업데이트하지 않은 라이더들을 삭제한다. 일정 시점을 기준으로 하기에 동시성 제어가 필요하지 않다. + * + * @author jun + */ + @Override + public void deleteNonUpdatedRiders() { + LocalDateTime now = LocalDateTime.now(); + Set keys = redisTemplate.opsForHash().keys(RedisKeyFactory.DELIVERY_KEY); + keys.stream().forEach(key -> { + Object obj = redisTemplate.opsForHash().get(RedisKeyFactory.DELIVERY_KEY, key); + if (Objects.isNull(obj) == false) { + DeliveryRiderDTO riderInfo = objectMapper.convertValue(obj, DeliveryRiderDTO.class); + if (ChronoUnit.SECONDS.between(riderInfo.getUpdatedAt(), now) > expireTime) { + redisTemplate.opsForHash().delete(RedisKeyFactory.DELIVERY_KEY, key); + log.info("Rider '{}' (이)가 스케줄에 의해 삭제됨", key); + } + } + }); + } + + @Override + public DeliveryRiderDTO getRiderInfo(String riderId) { + return objectMapper.convertValue( + redisTemplate.opsForHash().get(RedisKeyFactory.DELIVERY_KEY, riderId), + DeliveryRiderDTO.class); + } + + @Override + public List getRiderList() { + redisTemplate.watch(RedisKeyFactory.DELIVERY_KEY); + List riderList; + try { + List objList = redisTemplate.opsForHash().values(RedisKeyFactory.DELIVERY_KEY); + riderList = objList.stream().map(e -> objectMapper.convertValue(e, DeliveryRiderDTO.class)) + .collect(Collectors.toList()); + } finally { + redisTemplate.unwatch(); + } + return riderList; + } + + @Override + public void deleteAll(List idList) { + redisTemplate.watch(RedisKeyFactory.DELIVERY_KEY); + try { + redisTemplate.multi(); + idList.stream().forEach(id -> redisTemplate.delete(id)); + redisTemplate.exec(); + } catch (Exception e) { + redisTemplate.discard(); + } finally { + redisTemplate.unwatch(); + } + } + + /** + * Redis에 주문 상태 정보가 저장되어 있는지 확인한 후, 저장되어있으면 조회 후 리턴한다. 저장된 주문 정보가 없을 시 RDB에서 조회해 와 Redis에 저장한 후 + * 리턴한다. + * + * @author jun + */ + @Override + public OrderStatus getOrderStatus(Long orderId) { + OrderStatus status; + redisTemplate.watch(RedisKeyFactory.ORDER_KEY); + try { + Object object = redisTemplate.opsForHash().get(RedisKeyFactory.ORDER_KEY, orderId); + if (Objects.isNull(object)) { + status = orderService.getOrderStatus(orderId); + redisTemplate.opsForHash().put(RedisKeyFactory.ORDER_KEY, orderId, status); + } else { + status = objectMapper.convertValue(object, OrderStatus.class); + } + } finally { + redisTemplate.unwatch(); + } + return status; + } + + @Override + public void setOrderStatus(Long orderId, OrderStatus status) { + redisTemplate.opsForHash().put(RedisKeyFactory.ORDER_KEY, orderId, status); + } + + @Override + public void deleteOrderStatus(Long orderId) { + redisTemplate.opsForHash().delete(RedisKeyFactory.ORDER_KEY, orderId); + } +} diff --git a/src/main/java/com/delfood/dto/AddressDTO.java b/src/main/java/com/delfood/dto/address/AddressDTO.java similarity index 93% rename from src/main/java/com/delfood/dto/AddressDTO.java rename to src/main/java/com/delfood/dto/address/AddressDTO.java index 08f6005..42749b5 100644 --- a/src/main/java/com/delfood/dto/AddressDTO.java +++ b/src/main/java/com/delfood/dto/address/AddressDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.address; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/delfood/dto/DeliveryLocationDTO.java b/src/main/java/com/delfood/dto/address/DeliveryLocationDTO.java similarity index 85% rename from src/main/java/com/delfood/dto/DeliveryLocationDTO.java rename to src/main/java/com/delfood/dto/address/DeliveryLocationDTO.java index b08efd4..96165ff 100644 --- a/src/main/java/com/delfood/dto/DeliveryLocationDTO.java +++ b/src/main/java/com/delfood/dto/address/DeliveryLocationDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.address; import java.time.LocalDateTime; import lombok.Getter; diff --git a/src/main/java/com/delfood/dto/MemberDTO.java b/src/main/java/com/delfood/dto/member/MemberDTO.java similarity index 91% rename from src/main/java/com/delfood/dto/MemberDTO.java rename to src/main/java/com/delfood/dto/member/MemberDTO.java index 768b2b0..743b3ad 100644 --- a/src/main/java/com/delfood/dto/MemberDTO.java +++ b/src/main/java/com/delfood/dto/member/MemberDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.member; import java.time.LocalDateTime; import lombok.Getter; @@ -6,6 +6,7 @@ import lombok.Setter; import lombok.ToString; import org.springframework.lang.Nullable; +import com.delfood.dto.address.AddressDTO; // 고객 @Getter diff --git a/src/main/java/com/delfood/dto/MenuCategoryDTO.java b/src/main/java/com/delfood/dto/menu/MenuCategoryDTO.java similarity index 87% rename from src/main/java/com/delfood/dto/MenuCategoryDTO.java rename to src/main/java/com/delfood/dto/menu/MenuCategoryDTO.java index 51578f6..3f0acd3 100644 --- a/src/main/java/com/delfood/dto/MenuCategoryDTO.java +++ b/src/main/java/com/delfood/dto/menu/MenuCategoryDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.menu; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/delfood/dto/MenuDTO.java b/src/main/java/com/delfood/dto/menu/MenuDTO.java similarity index 93% rename from src/main/java/com/delfood/dto/MenuDTO.java rename to src/main/java/com/delfood/dto/menu/MenuDTO.java index 36db56d..98d51c1 100644 --- a/src/main/java/com/delfood/dto/MenuDTO.java +++ b/src/main/java/com/delfood/dto/menu/MenuDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.menu; import java.time.LocalDateTime; import java.util.List; diff --git a/src/main/java/com/delfood/dto/MenuGroupDTO.java b/src/main/java/com/delfood/dto/menu/MenuGroupDTO.java similarity index 91% rename from src/main/java/com/delfood/dto/MenuGroupDTO.java rename to src/main/java/com/delfood/dto/menu/MenuGroupDTO.java index ad8a172..2a5ac60 100644 --- a/src/main/java/com/delfood/dto/MenuGroupDTO.java +++ b/src/main/java/com/delfood/dto/menu/MenuGroupDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.menu; import java.time.LocalDateTime; import java.util.List; diff --git a/src/main/java/com/delfood/dto/OptionDTO.java b/src/main/java/com/delfood/dto/menu/OptionDTO.java similarity index 88% rename from src/main/java/com/delfood/dto/OptionDTO.java rename to src/main/java/com/delfood/dto/menu/OptionDTO.java index d2dabc2..2fd64ce 100644 --- a/src/main/java/com/delfood/dto/OptionDTO.java +++ b/src/main/java/com/delfood/dto/menu/OptionDTO.java @@ -1,6 +1,4 @@ -package com.delfood.dto; - -import com.delfood.dto.MenuDTO.Status; +package com.delfood.dto.menu; import java.time.LocalDateTime; import lombok.EqualsAndHashCode; @@ -10,6 +8,7 @@ import lombok.ToString; import org.apache.ibatis.type.Alias; +import com.delfood.dto.menu.MenuDTO.Status; @Getter @Setter diff --git a/src/main/java/com/delfood/dto/OrderDTO.java b/src/main/java/com/delfood/dto/order/OrderDTO.java similarity index 89% rename from src/main/java/com/delfood/dto/OrderDTO.java rename to src/main/java/com/delfood/dto/order/OrderDTO.java index f8fc829..86c01b0 100644 --- a/src/main/java/com/delfood/dto/OrderDTO.java +++ b/src/main/java/com/delfood/dto/order/OrderDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order; import java.time.LocalDateTime; import java.util.List; @@ -11,6 +11,8 @@ import org.apache.ibatis.type.Alias; import org.codehaus.commons.nullanalysis.Nullable; +import com.delfood.dto.order.coupon.SimpleCouponInfo; +import com.delfood.dto.order.item.OrderItemDTO; import com.fasterxml.jackson.annotation.JsonFormat; @Getter diff --git a/src/main/java/com/delfood/dto/ItemsBillDTO.java b/src/main/java/com/delfood/dto/order/bill/ItemsBillDTO.java similarity index 94% rename from src/main/java/com/delfood/dto/ItemsBillDTO.java rename to src/main/java/com/delfood/dto/order/bill/ItemsBillDTO.java index 2856503..0340bc6 100644 --- a/src/main/java/com/delfood/dto/ItemsBillDTO.java +++ b/src/main/java/com/delfood/dto/order/bill/ItemsBillDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.bill; import java.time.LocalDateTime; import java.util.ArrayList; @@ -6,6 +6,9 @@ import java.util.List; import java.util.stream.Collectors; import org.codehaus.jackson.annotate.JsonIgnore; +import com.delfood.dto.address.AddressDTO; +import com.delfood.dto.order.coupon.CouponDTO; +import com.delfood.dto.order.item.OrderItemDTO; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/delfood/dto/OrderBillDTO.java b/src/main/java/com/delfood/dto/order/bill/OrderBillDTO.java similarity index 72% rename from src/main/java/com/delfood/dto/OrderBillDTO.java rename to src/main/java/com/delfood/dto/order/bill/OrderBillDTO.java index 9281e07..7683d66 100644 --- a/src/main/java/com/delfood/dto/OrderBillDTO.java +++ b/src/main/java/com/delfood/dto/order/bill/OrderBillDTO.java @@ -1,7 +1,9 @@ -package com.delfood.dto; +package com.delfood.dto.order.bill; -import com.delfood.dto.ItemsBillDTO.MenuInfo; -import com.delfood.dto.OrderDTO.OrderStatus; +import com.delfood.dto.order.OrderDTO; +import com.delfood.dto.order.OrderDTO.OrderStatus; +import com.delfood.dto.order.bill.ItemsBillDTO.MenuInfo; +import com.delfood.dto.order.coupon.SimpleCouponInfo; import java.time.LocalDateTime; import java.util.List; import lombok.Getter; diff --git a/src/main/java/com/delfood/dto/CouponDTO.java b/src/main/java/com/delfood/dto/order/coupon/CouponDTO.java similarity index 92% rename from src/main/java/com/delfood/dto/CouponDTO.java rename to src/main/java/com/delfood/dto/order/coupon/CouponDTO.java index b332dc3..b779fcc 100644 --- a/src/main/java/com/delfood/dto/CouponDTO.java +++ b/src/main/java/com/delfood/dto/order/coupon/CouponDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.coupon; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Shape; diff --git a/src/main/java/com/delfood/dto/CouponIssueDTO.java b/src/main/java/com/delfood/dto/order/coupon/CouponIssueDTO.java similarity index 89% rename from src/main/java/com/delfood/dto/CouponIssueDTO.java rename to src/main/java/com/delfood/dto/order/coupon/CouponIssueDTO.java index 2525dbe..3db91d6 100644 --- a/src/main/java/com/delfood/dto/CouponIssueDTO.java +++ b/src/main/java/com/delfood/dto/order/coupon/CouponIssueDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.coupon; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/src/main/java/com/delfood/dto/SimpleCouponInfo.java b/src/main/java/com/delfood/dto/order/coupon/SimpleCouponInfo.java similarity index 85% rename from src/main/java/com/delfood/dto/SimpleCouponInfo.java rename to src/main/java/com/delfood/dto/order/coupon/SimpleCouponInfo.java index 7eb49b8..7781456 100644 --- a/src/main/java/com/delfood/dto/SimpleCouponInfo.java +++ b/src/main/java/com/delfood/dto/order/coupon/SimpleCouponInfo.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.coupon; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/delfood/dto/ItemDTO.java b/src/main/java/com/delfood/dto/order/item/ItemDTO.java similarity index 93% rename from src/main/java/com/delfood/dto/ItemDTO.java rename to src/main/java/com/delfood/dto/order/item/ItemDTO.java index d1e277a..d0cb2e2 100644 --- a/src/main/java/com/delfood/dto/ItemDTO.java +++ b/src/main/java/com/delfood/dto/order/item/ItemDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.item; import java.util.List; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/delfood/dto/OrderItemDTO.java b/src/main/java/com/delfood/dto/order/item/OrderItemDTO.java similarity index 76% rename from src/main/java/com/delfood/dto/OrderItemDTO.java rename to src/main/java/com/delfood/dto/order/item/OrderItemDTO.java index 46e5d3a..d3a6656 100644 --- a/src/main/java/com/delfood/dto/OrderItemDTO.java +++ b/src/main/java/com/delfood/dto/order/item/OrderItemDTO.java @@ -1,8 +1,8 @@ -package com.delfood.dto; +package com.delfood.dto.order.item; import java.time.LocalDateTime; import java.util.List; -import com.delfood.dto.OrderDTO.OrderStatus; +import com.delfood.dto.order.OrderDTO.OrderStatus; import lombok.Getter; import lombok.NonNull; import lombok.Setter; diff --git a/src/main/java/com/delfood/dto/OrderItemOptionDTO.java b/src/main/java/com/delfood/dto/order/item/OrderItemOptionDTO.java similarity index 74% rename from src/main/java/com/delfood/dto/OrderItemOptionDTO.java rename to src/main/java/com/delfood/dto/order/item/OrderItemOptionDTO.java index 85043cb..76f67d4 100644 --- a/src/main/java/com/delfood/dto/OrderItemOptionDTO.java +++ b/src/main/java/com/delfood/dto/order/item/OrderItemOptionDTO.java @@ -1,8 +1,8 @@ -package com.delfood.dto; +package com.delfood.dto.order.item; import java.time.LocalDateTime; import java.util.List; -import com.delfood.dto.OrderDTO.OrderStatus; +import com.delfood.dto.order.OrderDTO.OrderStatus; import lombok.Getter; import lombok.NonNull; import lombok.Setter; diff --git a/src/main/java/com/delfood/dto/OrdersItemDTO.java b/src/main/java/com/delfood/dto/order/item/OrdersItemDTO.java similarity index 89% rename from src/main/java/com/delfood/dto/OrdersItemDTO.java rename to src/main/java/com/delfood/dto/order/item/OrdersItemDTO.java index 6f68775..00c6dfc 100644 --- a/src/main/java/com/delfood/dto/OrdersItemDTO.java +++ b/src/main/java/com/delfood/dto/order/item/OrdersItemDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.item; import java.util.List; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/delfood/dto/OrdersItemOptionDTO.java b/src/main/java/com/delfood/dto/order/item/OrdersItemOptionDTO.java similarity index 83% rename from src/main/java/com/delfood/dto/OrdersItemOptionDTO.java rename to src/main/java/com/delfood/dto/order/item/OrdersItemOptionDTO.java index c72b5dd..cb465cc 100644 --- a/src/main/java/com/delfood/dto/OrdersItemOptionDTO.java +++ b/src/main/java/com/delfood/dto/order/item/OrdersItemOptionDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.order.item; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/delfood/dto/OwnerDTO.java b/src/main/java/com/delfood/dto/owner/OwnerDTO.java similarity index 92% rename from src/main/java/com/delfood/dto/OwnerDTO.java rename to src/main/java/com/delfood/dto/owner/OwnerDTO.java index 93a4e88..db182c0 100644 --- a/src/main/java/com/delfood/dto/OwnerDTO.java +++ b/src/main/java/com/delfood/dto/owner/OwnerDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.owner; import java.time.LocalDateTime; import lombok.Builder; diff --git a/src/main/java/com/delfood/dto/PaymentDTO.java b/src/main/java/com/delfood/dto/pay/PaymentDTO.java similarity index 94% rename from src/main/java/com/delfood/dto/PaymentDTO.java rename to src/main/java/com/delfood/dto/pay/PaymentDTO.java index 3eb20e4..61c0d35 100644 --- a/src/main/java/com/delfood/dto/PaymentDTO.java +++ b/src/main/java/com/delfood/dto/pay/PaymentDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.pay; import java.time.LocalDateTime; import lombok.Builder; diff --git a/src/main/java/com/delfood/dto/rider/DeliveryInfoDTO.java b/src/main/java/com/delfood/dto/rider/DeliveryInfoDTO.java index dacb572..410b3a9 100644 --- a/src/main/java/com/delfood/dto/rider/DeliveryInfoDTO.java +++ b/src/main/java/com/delfood/dto/rider/DeliveryInfoDTO.java @@ -1,7 +1,7 @@ package com.delfood.dto.rider; -import com.delfood.dto.OrderBillDTO.SimpleAddressInfo; -import com.delfood.dto.SimpleShopInfo; +import com.delfood.dto.order.bill.OrderBillDTO.SimpleAddressInfo; +import com.delfood.dto.shop.SimpleShopInfo; import java.time.LocalDateTime; import javax.annotation.Nullable; import lombok.Builder; diff --git a/src/main/java/com/delfood/dto/rider/DeliveryOrderInfo.java b/src/main/java/com/delfood/dto/rider/DeliveryOrderInfo.java index e03b9a1..e07c8b0 100644 --- a/src/main/java/com/delfood/dto/rider/DeliveryOrderInfo.java +++ b/src/main/java/com/delfood/dto/rider/DeliveryOrderInfo.java @@ -1,6 +1,6 @@ package com.delfood.dto.rider; -import com.delfood.dto.OrderDTO.OrderStatus; +import com.delfood.dto.order.OrderDTO.OrderStatus; import lombok.Getter; @Getter diff --git a/src/main/java/com/delfood/dto/rider/DeliveryRiderDTO.java b/src/main/java/com/delfood/dto/rider/DeliveryRiderDTO.java index 017e7c4..8a13296 100644 --- a/src/main/java/com/delfood/dto/rider/DeliveryRiderDTO.java +++ b/src/main/java/com/delfood/dto/rider/DeliveryRiderDTO.java @@ -10,6 +10,7 @@ @Getter @EqualsAndHashCode(of = "id") +@NoArgsConstructor public class DeliveryRiderDTO { @NonNull private String riderId; diff --git a/src/main/java/com/delfood/dto/ShopCategoryDTO.java b/src/main/java/com/delfood/dto/shop/ShopCategoryDTO.java similarity index 79% rename from src/main/java/com/delfood/dto/ShopCategoryDTO.java rename to src/main/java/com/delfood/dto/shop/ShopCategoryDTO.java index 294ca78..21d8aea 100644 --- a/src/main/java/com/delfood/dto/ShopCategoryDTO.java +++ b/src/main/java/com/delfood/dto/shop/ShopCategoryDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.shop; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/delfood/dto/ShopDTO.java b/src/main/java/com/delfood/dto/shop/ShopDTO.java similarity index 94% rename from src/main/java/com/delfood/dto/ShopDTO.java rename to src/main/java/com/delfood/dto/shop/ShopDTO.java index 22065a9..a35e071 100644 --- a/src/main/java/com/delfood/dto/ShopDTO.java +++ b/src/main/java/com/delfood/dto/shop/ShopDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.shop; import java.time.LocalDateTime; import java.util.List; diff --git a/src/main/java/com/delfood/dto/ShopUpdateDTO.java b/src/main/java/com/delfood/dto/shop/ShopUpdateDTO.java similarity index 94% rename from src/main/java/com/delfood/dto/ShopUpdateDTO.java rename to src/main/java/com/delfood/dto/shop/ShopUpdateDTO.java index 32aefc9..8bc5669 100644 --- a/src/main/java/com/delfood/dto/ShopUpdateDTO.java +++ b/src/main/java/com/delfood/dto/shop/ShopUpdateDTO.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.shop; import lombok.Getter; import lombok.NonNull; diff --git a/src/main/java/com/delfood/dto/SimpleShopInfo.java b/src/main/java/com/delfood/dto/shop/SimpleShopInfo.java similarity index 87% rename from src/main/java/com/delfood/dto/SimpleShopInfo.java rename to src/main/java/com/delfood/dto/shop/SimpleShopInfo.java index 5fce921..896f943 100644 --- a/src/main/java/com/delfood/dto/SimpleShopInfo.java +++ b/src/main/java/com/delfood/dto/shop/SimpleShopInfo.java @@ -1,4 +1,4 @@ -package com.delfood.dto; +package com.delfood.dto.shop; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/delfood/mapper/AddressMapper.java b/src/main/java/com/delfood/mapper/AddressMapper.java index 6acc9f8..aa06eac 100644 --- a/src/main/java/com/delfood/mapper/AddressMapper.java +++ b/src/main/java/com/delfood/mapper/AddressMapper.java @@ -2,7 +2,7 @@ import com.delfood.controller.reqeust.GetAddressByZipRequest; import com.delfood.controller.reqeust.GetAddressesByRoadRequest; -import com.delfood.dto.AddressDTO; +import com.delfood.dto.address.AddressDTO; import com.delfood.dto.address.Position; import java.util.List; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/delfood/mapper/CouponIssueMapper.java b/src/main/java/com/delfood/mapper/CouponIssueMapper.java index db19ae6..c9dbe3b 100644 --- a/src/main/java/com/delfood/mapper/CouponIssueMapper.java +++ b/src/main/java/com/delfood/mapper/CouponIssueMapper.java @@ -2,8 +2,8 @@ import java.util.List; import org.springframework.stereotype.Repository; -import com.delfood.dto.CouponIssueDTO; -import com.delfood.dto.ItemsBillDTO.CouponInfo; +import com.delfood.dto.order.bill.ItemsBillDTO.CouponInfo; +import com.delfood.dto.order.coupon.CouponIssueDTO; @Repository public interface CouponIssueMapper { diff --git a/src/main/java/com/delfood/mapper/CouponMapper.java b/src/main/java/com/delfood/mapper/CouponMapper.java index 6f99320..95142f5 100644 --- a/src/main/java/com/delfood/mapper/CouponMapper.java +++ b/src/main/java/com/delfood/mapper/CouponMapper.java @@ -1,9 +1,9 @@ package com.delfood.mapper; -import com.delfood.dto.CouponDTO; import java.time.LocalDateTime; import java.util.List; import org.springframework.stereotype.Repository; +import com.delfood.dto.order.coupon.CouponDTO; @Repository public interface CouponMapper { diff --git a/src/main/java/com/delfood/mapper/DeliveryLocationMapper.java b/src/main/java/com/delfood/mapper/DeliveryLocationMapper.java index 37e7173..d42f1f2 100644 --- a/src/main/java/com/delfood/mapper/DeliveryLocationMapper.java +++ b/src/main/java/com/delfood/mapper/DeliveryLocationMapper.java @@ -1,9 +1,9 @@ package com.delfood.mapper; -import com.delfood.dto.DeliveryLocationDTO; import java.util.List; import java.util.Set; import org.springframework.stereotype.Repository; +import com.delfood.dto.address.DeliveryLocationDTO; @Repository public interface DeliveryLocationMapper { diff --git a/src/main/java/com/delfood/mapper/MemberMapper.java b/src/main/java/com/delfood/mapper/MemberMapper.java index 476eaa7..886a156 100644 --- a/src/main/java/com/delfood/mapper/MemberMapper.java +++ b/src/main/java/com/delfood/mapper/MemberMapper.java @@ -2,7 +2,7 @@ import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; -import com.delfood.dto.MemberDTO; +import com.delfood.dto.member.MemberDTO; @Repository public interface MemberMapper { diff --git a/src/main/java/com/delfood/mapper/MenuGroupMapper.java b/src/main/java/com/delfood/mapper/MenuGroupMapper.java index f775d2f..2261c64 100644 --- a/src/main/java/com/delfood/mapper/MenuGroupMapper.java +++ b/src/main/java/com/delfood/mapper/MenuGroupMapper.java @@ -2,7 +2,7 @@ import java.util.List; import org.springframework.stereotype.Repository; -import com.delfood.dto.MenuGroupDTO; +import com.delfood.dto.menu.MenuGroupDTO; @Repository public interface MenuGroupMapper { diff --git a/src/main/java/com/delfood/mapper/MenuMapper.java b/src/main/java/com/delfood/mapper/MenuMapper.java index 03d8884..f14342c 100644 --- a/src/main/java/com/delfood/mapper/MenuMapper.java +++ b/src/main/java/com/delfood/mapper/MenuMapper.java @@ -1,8 +1,7 @@ package com.delfood.mapper; -import com.delfood.dto.MenuDTO; - import org.springframework.stereotype.Repository; +import com.delfood.dto.menu.MenuDTO; @Repository public interface MenuMapper { diff --git a/src/main/java/com/delfood/mapper/OptionMapper.java b/src/main/java/com/delfood/mapper/OptionMapper.java index 1d59d97..edc4bd1 100644 --- a/src/main/java/com/delfood/mapper/OptionMapper.java +++ b/src/main/java/com/delfood/mapper/OptionMapper.java @@ -1,8 +1,8 @@ package com.delfood.mapper; -import com.delfood.dto.OptionDTO; -import com.delfood.dto.OrderItemDTO; -import com.delfood.dto.OrderItemOptionDTO; +import com.delfood.dto.menu.OptionDTO; +import com.delfood.dto.order.item.OrderItemDTO; +import com.delfood.dto.order.item.OrderItemOptionDTO; import java.util.List; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/delfood/mapper/OrderMapper.java b/src/main/java/com/delfood/mapper/OrderMapper.java index 177ea32..ba1d5e8 100644 --- a/src/main/java/com/delfood/mapper/OrderMapper.java +++ b/src/main/java/com/delfood/mapper/OrderMapper.java @@ -1,11 +1,11 @@ package com.delfood.mapper; -import com.delfood.dto.OrderDTO; -import com.delfood.dto.OrderDTO.OrderStatus; -import com.delfood.dto.OrderItemDTO; -import com.delfood.dto.OrderItemOptionDTO; -import com.delfood.dto.ItemsBillDTO.MenuInfo; -import com.delfood.dto.OrderBillDTO; +import com.delfood.dto.order.OrderDTO; +import com.delfood.dto.order.OrderDTO.OrderStatus; +import com.delfood.dto.order.bill.OrderBillDTO; +import com.delfood.dto.order.bill.ItemsBillDTO.MenuInfo; +import com.delfood.dto.order.item.OrderItemDTO; +import com.delfood.dto.order.item.OrderItemOptionDTO; import java.time.LocalDateTime; import java.util.List; import lombok.NonNull; diff --git a/src/main/java/com/delfood/mapper/OwnerMapper.java b/src/main/java/com/delfood/mapper/OwnerMapper.java index ac440cc..81086d7 100644 --- a/src/main/java/com/delfood/mapper/OwnerMapper.java +++ b/src/main/java/com/delfood/mapper/OwnerMapper.java @@ -1,8 +1,7 @@ package com.delfood.mapper; -import com.delfood.dto.OwnerDTO; - import org.springframework.stereotype.Repository; +import com.delfood.dto.owner.OwnerDTO; @Repository public interface OwnerMapper { diff --git a/src/main/java/com/delfood/mapper/PaymentMapper.java b/src/main/java/com/delfood/mapper/PaymentMapper.java index 91a5345..a5a42fb 100644 --- a/src/main/java/com/delfood/mapper/PaymentMapper.java +++ b/src/main/java/com/delfood/mapper/PaymentMapper.java @@ -1,7 +1,7 @@ package com.delfood.mapper; import org.springframework.stereotype.Repository; -import com.delfood.dto.PaymentDTO; +import com.delfood.dto.pay.PaymentDTO; @Repository public interface PaymentMapper { diff --git a/src/main/java/com/delfood/mapper/ShopMapper.java b/src/main/java/com/delfood/mapper/ShopMapper.java index 3fce03a..fa88ceb 100644 --- a/src/main/java/com/delfood/mapper/ShopMapper.java +++ b/src/main/java/com/delfood/mapper/ShopMapper.java @@ -1,9 +1,9 @@ package com.delfood.mapper; -import com.delfood.dto.ItemsBillDTO.ShopInfo; -import com.delfood.dto.ItemsBillDTO; -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ShopUpdateDTO; +import com.delfood.dto.order.bill.ItemsBillDTO; +import com.delfood.dto.order.bill.ItemsBillDTO.ShopInfo; +import com.delfood.dto.shop.ShopDTO; +import com.delfood.dto.shop.ShopUpdateDTO; import java.util.List; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/delfood/mapper/ShopSearchMapper.java b/src/main/java/com/delfood/mapper/ShopSearchMapper.java index bb16a97..5ade097 100644 --- a/src/main/java/com/delfood/mapper/ShopSearchMapper.java +++ b/src/main/java/com/delfood/mapper/ShopSearchMapper.java @@ -1,7 +1,7 @@ package com.delfood.mapper; -import com.delfood.dto.ShopCategoryDTO; -import com.delfood.dto.ShopDTO; +import com.delfood.dto.shop.ShopCategoryDTO; +import com.delfood.dto.shop.ShopDTO; import java.util.List; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/delfood/service/AddressService.java b/src/main/java/com/delfood/service/AddressService.java index 364c35f..3f1d11f 100644 --- a/src/main/java/com/delfood/service/AddressService.java +++ b/src/main/java/com/delfood/service/AddressService.java @@ -2,7 +2,7 @@ import com.delfood.controller.reqeust.GetAddressByZipRequest; import com.delfood.controller.reqeust.GetAddressesByRoadRequest; -import com.delfood.dto.AddressDTO; +import com.delfood.dto.address.AddressDTO; import com.delfood.dto.address.Position; import com.delfood.mapper.AddressMapper; import lombok.extern.log4j.Log4j2; diff --git a/src/main/java/com/delfood/service/CartService.java b/src/main/java/com/delfood/service/CartService.java index e822611..c4f2f5b 100644 --- a/src/main/java/com/delfood/service/CartService.java +++ b/src/main/java/com/delfood/service/CartService.java @@ -1,9 +1,9 @@ package com.delfood.service; import com.delfood.dao.CartDao; -import com.delfood.dto.ItemDTO; -import com.delfood.dto.OptionDTO; -import com.delfood.dto.ItemDTO.CacheOptionDTO; +import com.delfood.dto.menu.OptionDTO; +import com.delfood.dto.order.item.ItemDTO; +import com.delfood.dto.order.item.ItemDTO.CacheOptionDTO; import com.delfood.error.exception.cart.DuplicateItemException; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/delfood/service/CouponIssueService.java b/src/main/java/com/delfood/service/CouponIssueService.java index 5dfa4c9..922cfd5 100644 --- a/src/main/java/com/delfood/service/CouponIssueService.java +++ b/src/main/java/com/delfood/service/CouponIssueService.java @@ -5,9 +5,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.delfood.dto.CouponDTO; -import com.delfood.dto.CouponIssueDTO; -import com.delfood.dto.ItemsBillDTO.CouponInfo; +import com.delfood.dto.order.bill.ItemsBillDTO.CouponInfo; +import com.delfood.dto.order.coupon.CouponDTO; +import com.delfood.dto.order.coupon.CouponIssueDTO; import com.delfood.error.exception.DuplicateException; import com.delfood.mapper.CouponIssueMapper; import lombok.extern.log4j.Log4j2; diff --git a/src/main/java/com/delfood/service/CouponService.java b/src/main/java/com/delfood/service/CouponService.java index fc7e8b5..1d713df 100644 --- a/src/main/java/com/delfood/service/CouponService.java +++ b/src/main/java/com/delfood/service/CouponService.java @@ -1,7 +1,7 @@ package com.delfood.service; -import com.delfood.dto.CouponDTO; -import com.delfood.dto.CouponDTO.DiscountType; +import com.delfood.dto.order.coupon.CouponDTO; +import com.delfood.dto.order.coupon.CouponDTO.DiscountType; import com.delfood.error.exception.coupon.IssuedCouponExistException; import com.delfood.mapper.CouponMapper; import java.time.LocalDateTime; diff --git a/src/main/java/com/delfood/service/MemberService.java b/src/main/java/com/delfood/service/MemberService.java index 2e4154a..d79da67 100644 --- a/src/main/java/com/delfood/service/MemberService.java +++ b/src/main/java/com/delfood/service/MemberService.java @@ -1,13 +1,11 @@ package com.delfood.service; -import com.delfood.dto.MemberDTO; +import com.delfood.dto.member.MemberDTO; import com.delfood.error.exception.DuplicateIdException; import com.delfood.mapper.MemberMapper; import com.delfood.utils.SHA256Util; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/delfood/service/MenuGroupService.java b/src/main/java/com/delfood/service/MenuGroupService.java index ef0d7d0..fa840a5 100644 --- a/src/main/java/com/delfood/service/MenuGroupService.java +++ b/src/main/java/com/delfood/service/MenuGroupService.java @@ -5,12 +5,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.delfood.dto.menu.MenuGroupDTO; import com.delfood.error.exception.TargetNotFoundException; import com.delfood.error.exception.TooManyModifiedException; import com.delfood.error.exception.menuGroup.InvalidMenuGroupCountException; import com.delfood.error.exception.menuGroup.InvalidMenuGroupIdException; import com.delfood.mapper.MenuGroupMapper; -import com.delfood.dto.MenuGroupDTO; @Service @Log4j2 diff --git a/src/main/java/com/delfood/service/MenuService.java b/src/main/java/com/delfood/service/MenuService.java index 2500463..fcc3c92 100644 --- a/src/main/java/com/delfood/service/MenuService.java +++ b/src/main/java/com/delfood/service/MenuService.java @@ -1,6 +1,6 @@ package com.delfood.service; -import com.delfood.dto.MenuDTO; +import com.delfood.dto.menu.MenuDTO; import com.delfood.mapper.MenuMapper; import java.util.List; diff --git a/src/main/java/com/delfood/service/MockPayService.java b/src/main/java/com/delfood/service/MockPayService.java index f13e7ed..9ee1a2e 100644 --- a/src/main/java/com/delfood/service/MockPayService.java +++ b/src/main/java/com/delfood/service/MockPayService.java @@ -1,7 +1,7 @@ package com.delfood.service; import com.delfood.aop.MemberLoginCheck; -import com.delfood.dto.PaymentDTO; +import com.delfood.dto.pay.PaymentDTO; import com.delfood.error.exception.mockPay.MockPayException; import lombok.NonNull; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/delfood/service/OptionService.java b/src/main/java/com/delfood/service/OptionService.java index 7753b83..7905d24 100644 --- a/src/main/java/com/delfood/service/OptionService.java +++ b/src/main/java/com/delfood/service/OptionService.java @@ -1,8 +1,8 @@ package com.delfood.service; -import com.delfood.dto.OptionDTO; -import com.delfood.dto.OrderItemDTO; -import com.delfood.dto.OrderItemOptionDTO; +import com.delfood.dto.menu.OptionDTO; +import com.delfood.dto.order.item.OrderItemDTO; +import com.delfood.dto.order.item.OrderItemOptionDTO; import com.delfood.mapper.OptionMapper; import java.util.List; import lombok.extern.log4j.Log4j2; diff --git a/src/main/java/com/delfood/service/OrderService.java b/src/main/java/com/delfood/service/OrderService.java index 8b990ef..bc9b7f1 100644 --- a/src/main/java/com/delfood/service/OrderService.java +++ b/src/main/java/com/delfood/service/OrderService.java @@ -1,17 +1,17 @@ package com.delfood.service; import com.delfood.controller.response.OrderResponse; -import com.delfood.dto.AddressDTO; -import com.delfood.dto.ItemsBillDTO; -import com.delfood.dto.ItemsBillDTO.ShopInfo; -import com.delfood.dto.OrderDTO.OrderStatus; -import com.delfood.dto.MemberDTO; -import com.delfood.dto.OrderBillDTO; -import com.delfood.dto.OrderDTO; -import com.delfood.dto.OrderItemDTO; -import com.delfood.dto.OrderItemOptionDTO; -import com.delfood.dto.PaymentDTO; -import com.delfood.dto.PaymentDTO.Type; +import com.delfood.dto.address.AddressDTO; +import com.delfood.dto.member.MemberDTO; +import com.delfood.dto.order.OrderDTO; +import com.delfood.dto.order.OrderDTO.OrderStatus; +import com.delfood.dto.order.bill.ItemsBillDTO; +import com.delfood.dto.order.bill.OrderBillDTO; +import com.delfood.dto.order.bill.ItemsBillDTO.ShopInfo; +import com.delfood.dto.order.item.OrderItemDTO; +import com.delfood.dto.order.item.OrderItemOptionDTO; +import com.delfood.dto.pay.PaymentDTO; +import com.delfood.dto.pay.PaymentDTO.Type; import com.delfood.dto.push.PushMessage; import com.delfood.mapper.OrderMapper; import com.delfood.utils.OrderUtil; diff --git a/src/main/java/com/delfood/service/OwnerService.java b/src/main/java/com/delfood/service/OwnerService.java index 265f477..a17d183 100644 --- a/src/main/java/com/delfood/service/OwnerService.java +++ b/src/main/java/com/delfood/service/OwnerService.java @@ -1,6 +1,6 @@ package com.delfood.service; -import com.delfood.dto.OwnerDTO; +import com.delfood.dto.owner.OwnerDTO; import com.delfood.error.exception.DuplicateException; import com.delfood.error.exception.DuplicateIdException; import com.delfood.mapper.OwnerMapper; diff --git a/src/main/java/com/delfood/service/PaymentService.java b/src/main/java/com/delfood/service/PaymentService.java index eb770d7..f872435 100644 --- a/src/main/java/com/delfood/service/PaymentService.java +++ b/src/main/java/com/delfood/service/PaymentService.java @@ -1,6 +1,6 @@ package com.delfood.service; -import com.delfood.dto.PaymentDTO; +import com.delfood.dto.pay.PaymentDTO; import com.delfood.mapper.PaymentMapper; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/delfood/service/ShopSearchService.java b/src/main/java/com/delfood/service/ShopSearchService.java index 1bc6290..8b9668e 100644 --- a/src/main/java/com/delfood/service/ShopSearchService.java +++ b/src/main/java/com/delfood/service/ShopSearchService.java @@ -1,7 +1,7 @@ package com.delfood.service; -import com.delfood.dto.ShopCategoryDTO; -import com.delfood.dto.ShopDTO; +import com.delfood.dto.shop.ShopCategoryDTO; +import com.delfood.dto.shop.ShopDTO; import com.delfood.mapper.ShopSearchMapper; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/delfood/service/ShopService.java b/src/main/java/com/delfood/service/ShopService.java index 7d0c030..7e9dbdd 100644 --- a/src/main/java/com/delfood/service/ShopService.java +++ b/src/main/java/com/delfood/service/ShopService.java @@ -1,9 +1,10 @@ package com.delfood.service; -import com.delfood.dto.AddressDTO; -import com.delfood.dto.DeliveryLocationDTO;import com.delfood.dto.ItemsBillDTO; -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ShopUpdateDTO; +import com.delfood.dto.address.AddressDTO; +import com.delfood.dto.address.DeliveryLocationDTO; +import com.delfood.dto.order.bill.ItemsBillDTO; +import com.delfood.dto.shop.ShopDTO; +import com.delfood.dto.shop.ShopUpdateDTO; import com.delfood.error.exception.shop.CanNotCloseShopException; import com.delfood.error.exception.shop.CanNotOpenShopException; import com.delfood.mapper.DeliveryLocationMapper; diff --git a/src/main/java/com/delfood/service/delivery/DeliveryService.java b/src/main/java/com/delfood/service/delivery/DeliveryService.java index dff694d..c125117 100644 --- a/src/main/java/com/delfood/service/delivery/DeliveryService.java +++ b/src/main/java/com/delfood/service/delivery/DeliveryService.java @@ -1,8 +1,8 @@ package com.delfood.service.delivery; import com.delfood.dao.deliveery.DeliveryDao; -import com.delfood.dto.OrderDTO.OrderStatus; import com.delfood.dto.address.Position; +import com.delfood.dto.order.OrderDTO.OrderStatus; import com.delfood.dto.push.PushMessage; import com.delfood.dto.rider.AcceptDeliveryRequestDTO; import com.delfood.dto.rider.DeliveryInfoDTO; @@ -32,7 +32,7 @@ public class DeliveryService { private static final long SCHEDULE_DELETE_DELIVERY_RIDER_SECOND = 300000; @Autowired - @Qualifier("multiThreadDeliveryDao") + @Qualifier("localMemoryDeliveryDao") private DeliveryDao deliveryDao; @Autowired diff --git a/src/main/java/com/delfood/utils/RedisKeyFactory.java b/src/main/java/com/delfood/utils/RedisKeyFactory.java index e73170c..65e21b3 100644 --- a/src/main/java/com/delfood/utils/RedisKeyFactory.java +++ b/src/main/java/com/delfood/utils/RedisKeyFactory.java @@ -1,8 +1,13 @@ package com.delfood.utils; public class RedisKeyFactory { + + public static final String DELIVERY_KEY = "DELIVERIES"; + + public static final String ORDER_KEY = "ORDERS"; + public enum Key { - CART, FCM_MEMBER, FCM_OWNER, FCM_MEMBER_ERROR, FCM_OWNER_ERROR, FCM_RIDER + CART, FCM_MEMBER, FCM_OWNER, FCM_MEMBER_ERROR, FCM_OWNER_ERROR, FCM_RIDER, DELIVERIES } // 인스턴스화 방지 diff --git a/src/main/java/com/delfood/vo/MemberVO.java b/src/main/java/com/delfood/vo/MemberVO.java deleted file mode 100644 index 85dc3c5..0000000 --- a/src/main/java/com/delfood/vo/MemberVO.java +++ /dev/null @@ -1,42 +0,0 @@ - -package com.delfood.vo; - -public class MemberVO { - - private String mem_id; - private String mem_pw; - private String mem_name; - private String mem_mail; - private String mem_phone; - - public String getMem_id() { - return mem_id; - } - public void setMem_id(String mem_id) { - this.mem_id = mem_id; - } - public String getMem_pw() { - return mem_pw; - } - public void setMem_pw(String mem_pw) { - this.mem_pw = mem_pw; - } - public String getMem_name() { - return mem_name; - } - public void setMem_name(String mem_name) { - this.mem_name = mem_name; - } - public String getMem_mail() { - return mem_mail; - } - public void setMem_mail(String mem_mail) { - this.mem_mail = mem_mail; - } - public String getMem_phone() { - return mem_phone; - } - public void setMem_phone(String mem_phone) { - this.mem_phone = mem_phone; - } -} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 5c90be9..48388d2 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -11,6 +11,11 @@ expir.default=36288000 expire.cart=3600 expire.fcm.member=36288000 expire.fcm.owner=36288000 +<<<<<<< HEAD +expire.fcm.rider=36288000 +======= +expire.rider=300 +>>>>>>> refs/remotes/yyy9942/feature/delivery_dao_redis # Log diff --git a/src/main/resources/application-release.properties b/src/main/resources/application-release.properties new file mode 100644 index 0000000..ab34bb8 --- /dev/null +++ b/src/main/resources/application-release.properties @@ -0,0 +1,55 @@ +# DB +spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy + +# redis +spring.redis.host=10.41.2.194 +spring.redis.port=6379 +spring.redis.password= + +# expire +expir.default=36288000 +expire.cart=3600 +expire.fcm.member=36288000 +expire.fcm.owner=36288000 +expire.fcm.rider=36288000 + + +# Log +#logback 설정 +#로그파일 dev/local/release +log.config.mode=release +#로그파일 저장 분기 ZIP이면 ZIP파일로 저장 LOG이면 LOG파일로 일자별 저장 +#log.config.savemode=ZIP +log.config.savemode=LOG + +#ZIP모드일 경우에만 사용 + +#로그파일 최소 개수 +log.config.min=1 +#로그파일 최대 개수 +log.config.max=30 +#로그파일 사이즈 +log.config.filesizezip=10MB + +#ZIP모드일 경우에만 사용 + +#LOG모드일 경우에만 사용 +#로그파일 기간설정 +log.config.days=30 +#로그파일 사이즈 +log.config.filesizelog=100MB +#로그파일 최대 최대 사이즈 +log.config.totalfilesize=10GB +#LOG모드일 경우에만 사용 +#공통 설정 +#프로젝트 패키지 명 +log.config.packagename=com.delfood +#로그파일 경로 +log.config.path=/home/delfood/log +#로그파일 이름 +log.config.filename=delfood-release + +logging.level.jdbc.sqlonly=DEBUG + +# FCM +fcm.key.path=delfood-8385c-firebase-adminsdk-p6vk2-9d667ced9e.json \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e9dd540..e99e778 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,7 +2,7 @@ server.port=80 # profile -spring.profiles.active=local +spring.profiles.active=release # session spring.session.store-type=redis \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/address.xml b/src/main/resources/mybatis/mapper/address.xml index bdf9382..1f7e668 100644 --- a/src/main/resources/mybatis/mapper/address.xml +++ b/src/main/resources/mybatis/mapper/address.xml @@ -23,7 +23,7 @@ exit_y_coordinate exitYCoordinate FROM ADDRESS - SELECT DISTINCT A.town_code townCode, A.city_name cityName, @@ -37,7 +37,7 @@ LIMIT 10 - SELECT DISTINCT A.town_code townCode, A.city_name cityName, @@ -51,7 +51,7 @@ LIMIT 10 - WHERE 1 = 1 AND town_name LIKE CONCAT(IFNULL(#{townName}, ''), '%') @@ -63,7 +63,7 @@ LIMIT 10 - WHERE 1 = 1 AND road_name LIKE CONCAT(IFNULL(#{roadName}, ''), '%') diff --git a/src/main/resources/mybatis/mapper/coupon.xml b/src/main/resources/mybatis/mapper/coupon.xml index 2374059..7aad0d9 100644 --- a/src/main/resources/mybatis/mapper/coupon.xml +++ b/src/main/resources/mybatis/mapper/coupon.xml @@ -2,7 +2,7 @@ - + INSERT INTO COUPON(name, discount_type, discount_value, end_at) VALUES(#{name}, #{discountType}, #{discountValue}, #{endAt}) @@ -24,7 +24,7 @@ WHERE id = #{id} - SELECT id, name, discount_type, discount_value, created_at, end_at FROM COUPON WHERE end_at > NOW() diff --git a/src/main/resources/mybatis/mapper/couponIssue.xml b/src/main/resources/mybatis/mapper/couponIssue.xml index b30c249..4e637a5 100644 --- a/src/main/resources/mybatis/mapper/couponIssue.xml +++ b/src/main/resources/mybatis/mapper/couponIssue.xml @@ -25,7 +25,7 @@ WHERE id = #{id} - SELECT i.id, i.created_at createdAt, i.status, i.coupon_id couponId, i.member_id memberId, i.payment_id paymentId ,c.name, c.discount_type discountType, c.discount_value discountValue, c.end_at endAt FROM COUPON_ISSUE i @@ -35,7 +35,7 @@ AND i.status = 'DEFAULT' - SELECT i.id couponIssueId, c.id couponId, i.member_id memberId, @@ -49,7 +49,7 @@ AND i.id = #{couponIssueId} - SELECT id, member_id memberId, coupon_id couponId, created_at createdAt, status, payment_id paymentId FROM COUPON_ISSUE WHERE id = #{id} diff --git a/src/main/resources/mybatis/mapper/deliveryLocation.xml b/src/main/resources/mybatis/mapper/deliveryLocation.xml index 4cbcbb1..3e9d89c 100644 --- a/src/main/resources/mybatis/mapper/deliveryLocation.xml +++ b/src/main/resources/mybatis/mapper/deliveryLocation.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - SELECT DISTINCT A.town_code townCode, A.city_name cityName, @@ -23,7 +23,7 @@ LIMIT 10 - SELECT id, shop_id shopId, town_code townCode, diff --git a/src/main/resources/mybatis/mapper/member.xml b/src/main/resources/mybatis/mapper/member.xml index b86c3f8..c2ed17e 100644 --- a/src/main/resources/mybatis/mapper/member.xml +++ b/src/main/resources/mybatis/mapper/member.xml @@ -2,7 +2,7 @@ - + @@ -13,10 +13,10 @@ - + - SELECT town_code townCode, city_name cityName, city_country_name cityCountryName, @@ -45,12 +45,12 @@ AND status != 'DELETE' - + INSERT INTO MEMBER(id, password, name, tel, mail, address_code, address_detail) VALUES(#{id}, #{password}, #{name}, #{tel}, #{mail}, #{addressCode}, #{addressDetail}) - SELECT * FROM MEMBER WHERE id = #{id} diff --git a/src/main/resources/mybatis/mapper/menu.xml b/src/main/resources/mybatis/mapper/menu.xml index 34988aa..4ad8f4a 100644 --- a/src/main/resources/mybatis/mapper/menu.xml +++ b/src/main/resources/mybatis/mapper/menu.xml @@ -2,7 +2,7 @@ - + @@ -13,7 +13,7 @@ - + @@ -22,7 +22,7 @@ FROM MENU - + INSERT INTO MENU(name, price, photo, priority, content, menu_group_id) VALUES(#{name}, #{price}, #{photo}, (SELECT MAX(priority)+1 FROM MENU MENUS WHERE menu_group_id = #{menuGroupId}), @@ -51,7 +51,7 @@ WHERE id = #{id} - + UPDATE MENU SET name = #{name}, price = #{price}, @@ -60,7 +60,7 @@ WHERE id = #{id} - SELECT id, name, price, photo, content FROM MENU WHERE id = #{id} @@ -79,7 +79,7 @@ WHERE id = #{id} - SELECT id, name, price, status, menu_id menuId FROM OPTION WHERE menu_id = #{id} diff --git a/src/main/resources/mybatis/mapper/menuGroup.xml b/src/main/resources/mybatis/mapper/menuGroup.xml index 61b53e2..6cf807e 100644 --- a/src/main/resources/mybatis/mapper/menuGroup.xml +++ b/src/main/resources/mybatis/mapper/menuGroup.xml @@ -2,7 +2,7 @@ - + @@ -11,7 +11,7 @@ - + @@ -24,7 +24,7 @@ FROM MENU - + INSERT INTO MENU_GROUP(name, content, shop_id, priority) VALUES( #{name}, #{content}, #{shopId}, (SELECT MAX(priority)+1 FROM MENU_GROUP MENUGROUP WHERE shop_id = #{shopId})) @@ -35,7 +35,7 @@ WHERE name = #{name} - WHERE shop_id = #{shopId} AND status != "DELETED" @@ -54,7 +54,7 @@ WHERE id = #{id} - WHERE menuGroupId = #{menuGroupId} AND status != "DELETED" diff --git a/src/main/resources/mybatis/mapper/option.xml b/src/main/resources/mybatis/mapper/option.xml index 9f41704..5afe05b 100644 --- a/src/main/resources/mybatis/mapper/option.xml +++ b/src/main/resources/mybatis/mapper/option.xml @@ -2,13 +2,13 @@ - SELECT id, name, price, status, menu_id menuId FROM OPTION WHERE id = #{id} - + INSERT INTO OPTION(name, price, menu_id) VALUES(#{name}, #{price}, #{menuId}) @@ -33,7 +33,7 @@ WHERE opt.id IN (#{option.optionId}) - SELECT id, name, price, status, menu_id menuId FROM OPTION WHERE id = #{id} diff --git a/src/main/resources/mybatis/mapper/orders.xml b/src/main/resources/mybatis/mapper/orders.xml index 55e2b66..a25fb14 100644 --- a/src/main/resources/mybatis/mapper/orders.xml +++ b/src/main/resources/mybatis/mapper/orders.xml @@ -1,7 +1,7 @@ - + @@ -22,13 +22,13 @@ - + - + @@ -39,7 +39,7 @@ - SELECT A.town_code townCode, A.city_name cityName, A.city_country_name cityCountryName, @@ -175,7 +175,7 @@ - + @@ -199,11 +199,11 @@ - + - + @@ -263,11 +263,11 @@ - + - + @@ -370,7 +370,7 @@ WHERE odr.id = #{orderId} - SELECT odr.order_status orderStatus FROM ORDERS odr WHERE odr.id = #{orderId} diff --git a/src/main/resources/mybatis/mapper/owner.xml b/src/main/resources/mybatis/mapper/owner.xml index 4c1a50a..68d7b1e 100644 --- a/src/main/resources/mybatis/mapper/owner.xml +++ b/src/main/resources/mybatis/mapper/owner.xml @@ -1,7 +1,7 @@ - + INSERT INTO OWNER(id, password, name, mail, tel) VALUES (#{id}, #{password}, #{name}, #{mail}, #{tel}) @@ -12,14 +12,14 @@ WHERE id = #{id} - SELECT id, password, name, mail, tel, created_at createdAt, updated_at updatedAt, status FROM OWNER WHERE id = #{id} AND password = #{password} - SELECT id, password, name, mail, tel, created_at createdAt, updated_at updatedAt, status FROM OWNER WHERE id = #{id} diff --git a/src/main/resources/mybatis/mapper/shop.xml b/src/main/resources/mybatis/mapper/shop.xml index fb51671..3330500 100644 --- a/src/main/resources/mybatis/mapper/shop.xml +++ b/src/main/resources/mybatis/mapper/shop.xml @@ -25,7 +25,7 @@ - + INSERT INTO SHOP( name, delivery_type, @@ -67,7 +67,7 @@ WHERE id = #{id} - WHERE owner_id = #{ownerId} AND id > #{lastId} @@ -75,7 +75,7 @@ - WHERE id = #{id} @@ -142,7 +142,7 @@ AND work_condition != 'OPEN' - SELECT A.id, A.name, A.delivery_type deliveryType, @@ -157,7 +157,7 @@ - SELECT id, name FROM SHOP WHERE status != 'DELETE' @@ -165,7 +165,7 @@ AND work_condition = 'CLOSE' - SELECT id, name FROM SHOP WHERE status != 'DELETE' @@ -173,7 +173,7 @@ AND work_condition = 'OPEN' - SELECT s.id, s.name, address_code addressCode FROM SHOP s JOIN MENU_GROUP g ON (s.id = g.shop_id) JOIN MENU m ON (g.id = m.menu_group_id) diff --git a/src/main/resources/mybatis/mapper/shopSearch.xml b/src/main/resources/mybatis/mapper/shopSearch.xml index 554ccc2..de92c95 100644 --- a/src/main/resources/mybatis/mapper/shopSearch.xml +++ b/src/main/resources/mybatis/mapper/shopSearch.xml @@ -1,13 +1,13 @@ - SELECT id, name FROM SHOP_CATEGORY - SELECT DISTINCT A.id, A.name, diff --git a/src/test/java/com/delfood/config/RedisConfigTest.java b/src/test/java/com/delfood/config/RedisConfigTest.java index 6573cf7..10226c9 100644 --- a/src/test/java/com/delfood/config/RedisConfigTest.java +++ b/src/test/java/com/delfood/config/RedisConfigTest.java @@ -11,8 +11,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.test.context.junit4.SpringRunner; - -import com.delfood.dto.MemberDTO; +import com.delfood.dto.member.MemberDTO; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.log4j.Log4j2; diff --git a/src/test/java/com/delfood/controller/MemberControllerTest.java b/src/test/java/com/delfood/controller/MemberControllerTest.java index 7212417..d9a5aff 100644 --- a/src/test/java/com/delfood/controller/MemberControllerTest.java +++ b/src/test/java/com/delfood/controller/MemberControllerTest.java @@ -27,7 +27,7 @@ import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.transaction.annotation.Transactional; -import com.delfood.dto.MemberDTO; +import com.delfood.dto.member.MemberDTO; import com.delfood.service.MemberService; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.log4j.Log4j2; diff --git a/src/test/java/com/delfood/service/AddressServiceTest.java b/src/test/java/com/delfood/service/AddressServiceTest.java index 5c4d674..bd34377 100644 --- a/src/test/java/com/delfood/service/AddressServiceTest.java +++ b/src/test/java/com/delfood/service/AddressServiceTest.java @@ -6,7 +6,7 @@ import com.delfood.controller.reqeust.GetAddressByZipRequest; import com.delfood.controller.reqeust.GetAddressesByRoadRequest; -import com.delfood.dto.AddressDTO; +import com.delfood.dto.address.AddressDTO; import com.delfood.dto.address.Position; import com.delfood.mapper.AddressMapper; import java.util.ArrayList; diff --git a/src/test/java/com/delfood/service/CartServiceTest.java b/src/test/java/com/delfood/service/CartServiceTest.java index c46e09a..b42e924 100644 --- a/src/test/java/com/delfood/service/CartServiceTest.java +++ b/src/test/java/com/delfood/service/CartServiceTest.java @@ -7,11 +7,11 @@ import java.util.Arrays; import java.util.List; import com.delfood.dao.CartDao; -import com.delfood.dto.ItemDTO; -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ItemDTO.CacheMenuDTO; -import com.delfood.dto.ItemDTO.CacheOptionDTO; -import com.delfood.dto.ItemDTO.CacheShopDTO; +import com.delfood.dto.order.item.ItemDTO; +import com.delfood.dto.order.item.ItemDTO.CacheMenuDTO; +import com.delfood.dto.order.item.ItemDTO.CacheOptionDTO; +import com.delfood.dto.order.item.ItemDTO.CacheShopDTO; +import com.delfood.dto.shop.ShopDTO; import com.delfood.error.exception.cart.DuplicateItemException; import com.google.common.collect.Lists; import org.junit.Test; diff --git a/src/test/java/com/delfood/service/CouponServiceTest.java b/src/test/java/com/delfood/service/CouponServiceTest.java index 84e686c..14ad8d6 100644 --- a/src/test/java/com/delfood/service/CouponServiceTest.java +++ b/src/test/java/com/delfood/service/CouponServiceTest.java @@ -2,10 +2,9 @@ import static org.mockito.BDDMockito.given; import static org.assertj.core.api.Assertions.assertThat; - -import com.delfood.dto.CouponDTO; -import com.delfood.dto.CouponDTO.DiscountType; -import com.delfood.dto.CouponDTO.Status; +import com.delfood.dto.order.coupon.CouponDTO; +import com.delfood.dto.order.coupon.CouponDTO.DiscountType; +import com.delfood.dto.order.coupon.CouponDTO.Status; import com.delfood.error.exception.coupon.IssuedCouponExistException; import com.delfood.mapper.CouponMapper; import java.time.LocalDateTime; diff --git a/src/test/java/com/delfood/service/MemberServiceTest.java b/src/test/java/com/delfood/service/MemberServiceTest.java index 0d5a0ac..13ed899 100644 --- a/src/test/java/com/delfood/service/MemberServiceTest.java +++ b/src/test/java/com/delfood/service/MemberServiceTest.java @@ -2,8 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.MemberDTO; +import com.delfood.dto.member.MemberDTO; import com.delfood.mapper.MemberMapper; import com.delfood.utils.SHA256Util; import java.time.LocalDateTime; diff --git a/src/test/java/com/delfood/service/MenuGroupServiceTest.java b/src/test/java/com/delfood/service/MenuGroupServiceTest.java index 19f3025..17a2540 100644 --- a/src/test/java/com/delfood/service/MenuGroupServiceTest.java +++ b/src/test/java/com/delfood/service/MenuGroupServiceTest.java @@ -2,9 +2,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.MenuGroupDTO; -import com.delfood.dto.MenuGroupDTO.Status; +import com.delfood.dto.menu.MenuGroupDTO; +import com.delfood.dto.menu.MenuGroupDTO.Status; import com.delfood.error.exception.TargetNotFoundException; import com.delfood.error.exception.TooManyModifiedException; import com.delfood.error.exception.menuGroup.InvalidMenuGroupCountException; diff --git a/src/test/java/com/delfood/service/MenuServiceTest.java b/src/test/java/com/delfood/service/MenuServiceTest.java index b1e703b..9ad8f68 100644 --- a/src/test/java/com/delfood/service/MenuServiceTest.java +++ b/src/test/java/com/delfood/service/MenuServiceTest.java @@ -4,10 +4,9 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.MenuDTO; -import com.delfood.dto.MenuDTO.Status; -import com.delfood.dto.OptionDTO; +import com.delfood.dto.menu.MenuDTO; +import com.delfood.dto.menu.OptionDTO; +import com.delfood.dto.menu.MenuDTO.Status; import com.delfood.mapper.MenuMapper; import java.time.LocalDateTime; import java.util.ArrayList; diff --git a/src/test/java/com/delfood/service/MockPayServiceTest.java b/src/test/java/com/delfood/service/MockPayServiceTest.java new file mode 100644 index 0000000..3fc6dad --- /dev/null +++ b/src/test/java/com/delfood/service/MockPayServiceTest.java @@ -0,0 +1,41 @@ +package com.delfood.service; + +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Before; +import org.junit.Test; +import com.delfood.dto.pay.PaymentDTO; +import com.delfood.dto.pay.PaymentDTO.Status; +import com.delfood.dto.pay.PaymentDTO.Type; +import com.delfood.error.exception.mockPay.MockPayException; + +public class MockPayServiceTest { + + MockPayService service; + + @Before + public void init() { + service = new MockPayService(); + } + + + + @Test + public void mockPayTest_가상결제_성공_테스트() { + PaymentDTO payInfo = PaymentDTO.builder().amountDiscount(0L).amountPayment(10000L).orderId(1L) + .type(Type.CARD).build(); + + assertThat(payInfo.getStatus()).isEqualTo(Status.READY); + assertThat(service.pay(payInfo).getStatus()).isEqualTo(Status.SUCCESS); + } + + @Test(expected = MockPayException.class) + public void mockPayFailTest_가상결제_실패_테스트() { + PaymentDTO payInfo = PaymentDTO.builder().amountDiscount(0L).amountPayment(10000L).orderId(1L) + .type(Type.CARD).build(); + payInfo.doFail(); + + assertThat(service.pay(payInfo)); + } + + +} diff --git a/src/test/java/com/delfood/service/OptionServiceTest.java b/src/test/java/com/delfood/service/OptionServiceTest.java index 87e1e50..e960267 100644 --- a/src/test/java/com/delfood/service/OptionServiceTest.java +++ b/src/test/java/com/delfood/service/OptionServiceTest.java @@ -2,9 +2,8 @@ import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.OptionDTO; -import com.delfood.dto.OptionDTO.Status; +import com.delfood.dto.menu.OptionDTO; +import com.delfood.dto.menu.OptionDTO.Status; import com.delfood.mapper.OptionMapper; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/com/delfood/service/OrderServiceTest.java b/src/test/java/com/delfood/service/OrderServiceTest.java index 51440a9..8b8f105 100644 --- a/src/test/java/com/delfood/service/OrderServiceTest.java +++ b/src/test/java/com/delfood/service/OrderServiceTest.java @@ -17,21 +17,21 @@ import org.mockito.stubbing.Answer; import org.springframework.boot.test.mock.mockito.MockBean; import com.delfood.controller.response.OrderResponse; -import com.delfood.dto.AddressDTO; -import com.delfood.dto.ItemsBillDTO; -import com.delfood.dto.ItemsBillDTO.MenuInfo; -import com.delfood.dto.ItemsBillDTO.ShopInfo; -import com.delfood.dto.MemberDTO; -import com.delfood.dto.OrderDTO; -import com.delfood.dto.OrderDTO.OrderStatus; -import com.delfood.dto.OrderItemDTO; -import com.delfood.dto.OrderItemOptionDTO; -import com.delfood.dto.PaymentDTO; -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ShopDTO.DeliveryType; -import com.delfood.dto.ShopDTO.OrderType; -import com.delfood.dto.ShopDTO.Status; +import com.delfood.dto.address.AddressDTO; import com.delfood.dto.address.Position; +import com.delfood.dto.member.MemberDTO; +import com.delfood.dto.order.OrderDTO; +import com.delfood.dto.order.OrderDTO.OrderStatus; +import com.delfood.dto.order.bill.ItemsBillDTO; +import com.delfood.dto.order.bill.ItemsBillDTO.MenuInfo; +import com.delfood.dto.order.bill.ItemsBillDTO.ShopInfo; +import com.delfood.dto.order.item.OrderItemDTO; +import com.delfood.dto.order.item.OrderItemOptionDTO; +import com.delfood.dto.pay.PaymentDTO; +import com.delfood.dto.shop.ShopDTO; +import com.delfood.dto.shop.ShopDTO.DeliveryType; +import com.delfood.dto.shop.ShopDTO.OrderType; +import com.delfood.dto.shop.ShopDTO.Status; import com.delfood.mapper.AddressMapper; import com.delfood.mapper.MemberMapper; import com.delfood.mapper.OrderMapper; diff --git a/src/test/java/com/delfood/service/OwnerServiceTest.java b/src/test/java/com/delfood/service/OwnerServiceTest.java index 5ced618..6379a49 100644 --- a/src/test/java/com/delfood/service/OwnerServiceTest.java +++ b/src/test/java/com/delfood/service/OwnerServiceTest.java @@ -2,8 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.OwnerDTO; +import com.delfood.dto.owner.OwnerDTO; import com.delfood.error.exception.DuplicateException; import com.delfood.mapper.OwnerMapper; import com.delfood.utils.SHA256Util; diff --git a/src/test/java/com/delfood/service/ShopServiceTest.java b/src/test/java/com/delfood/service/ShopServiceTest.java index 47e6d41..9482b85 100644 --- a/src/test/java/com/delfood/service/ShopServiceTest.java +++ b/src/test/java/com/delfood/service/ShopServiceTest.java @@ -1,11 +1,10 @@ package com.delfood.service; import static org.mockito.BDDMockito.given; - -import com.delfood.dto.ShopDTO; -import com.delfood.dto.ShopDTO.DeliveryType; -import com.delfood.dto.ShopDTO.OrderType; -import com.delfood.dto.ShopDTO.Status; +import com.delfood.dto.shop.ShopDTO; +import com.delfood.dto.shop.ShopDTO.DeliveryType; +import com.delfood.dto.shop.ShopDTO.OrderType; +import com.delfood.dto.shop.ShopDTO.Status; import com.delfood.mapper.DeliveryLocationMapper; import com.delfood.mapper.ShopMapper; diff --git a/src/test/java/com/delfood/service/delivery/DeliveryServiceTest.java b/src/test/java/com/delfood/service/delivery/DeliveryServiceTest.java new file mode 100644 index 0000000..0d13b5c --- /dev/null +++ b/src/test/java/com/delfood/service/delivery/DeliveryServiceTest.java @@ -0,0 +1,86 @@ +package com.delfood.service.delivery; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import com.delfood.dao.deliveery.DeliveryDao; +import com.delfood.dto.address.Position; +import com.delfood.dto.push.PushMessage; +import com.delfood.dto.rider.DeliveryRiderDTO; +import com.delfood.service.PushService; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class DeliveryServiceTest { + + @InjectMocks + public DeliveryService deliveryService; + + @Mock + public DeliveryDao deliveryDao; + + @Mock + public PushService pushService; + + public List generateRiders() { + List riderList = new ArrayList<>(); + riderList.add(DeliveryRiderDTO.builder().riderId("rider001") + .position(Position.builder().coordinateX(500d).coordinateY(400d).build()).build()); // 500m + riderList.add(DeliveryRiderDTO.builder().riderId("rider002") + .position(Position.builder().coordinateX(900d).coordinateY(750.235d).build()).build()); // 1030m + riderList.add(DeliveryRiderDTO.builder().riderId("rider003") + .position(Position.builder().coordinateX(100.213d).coordinateY(0.222).build()).build()); // 99.77m + riderList.add(DeliveryRiderDTO.builder().riderId("rider004") + .position(Position.builder().coordinateX(0d).coordinateY(9000d).build()).build()); // 8900m + riderList.add(DeliveryRiderDTO.builder().riderId("rider005") + .position(Position.builder().coordinateX(99999d).coordinateY(99999d).build()).build()); // 141278.5 + return riderList; + } + + @Test + public void deliveryRequestByDistanceTest_거리기반_푸시메세지_전송_1000미터() { + Position position = new Position(100.0, 100.0); + long distance = 1000L; // 1Km + + List riderList = generateRiders(); + given(deliveryDao.getRiderList()).willReturn(riderList); + doNothing().when(pushService).sendMessageToRider(any(), anyString()); + + deliveryService.deliveryRequestByDistance(position, distance); + + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider001"); + verify(pushService, times(0)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider002"); + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider003"); + verify(pushService, times(0)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider004"); + verify(pushService, times(0)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider005"); + } + + @Test + public void deliveryRequestByDistanceTest_거리기반_푸시메세지_전송_100000미터() { + Position position = new Position(100.0, 100.0); + long distance = 100000L; // 1Km + + List riderList = generateRiders(); + given(deliveryDao.getRiderList()).willReturn(riderList); + doNothing().when(pushService).sendMessageToRider(any(), anyString()); + + deliveryService.deliveryRequestByDistance(position, distance); + + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider001"); + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider002"); + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider003"); + verify(pushService, times(1)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider004"); + verify(pushService, times(0)).sendMessageToRider(PushMessage.DELIVERY_REQUEST, "rider005"); + } + +} diff --git a/src/test/java/com/delfood/service/rider/RiderInfoServiceTest.java b/src/test/java/com/delfood/service/rider/RiderInfoServiceTest.java new file mode 100644 index 0000000..2a33bce --- /dev/null +++ b/src/test/java/com/delfood/service/rider/RiderInfoServiceTest.java @@ -0,0 +1,144 @@ +package com.delfood.service.rider; + +import static org.mockito.Mockito.when; + +import com.delfood.dto.rider.RiderDTO; +import com.delfood.dto.rider.RiderDTO.Status; +import com.delfood.error.exception.DuplicateException; +import com.delfood.error.exception.IdDeletedException; +import com.delfood.mapper.RiderInfoMapper; +import com.delfood.utils.SHA256Util; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class RiderInfoServiceTest { + + @InjectMocks + public RiderInfoService riderInfoService; + + @Mock + public RiderInfoMapper riderInfoMapper; + + public RiderDTO generateRider() { + return RiderDTO.builder().id("testId").password(SHA256Util.encryptSHA256("testPassword")) + .name("testName").status(Status.DEFAULT).tel("010-1111-2222").build(); + } + + public RiderDTO generateDeletedRider() { + return RiderDTO.builder().id("testId").password(SHA256Util.encryptSHA256("testPassword")) + .name("testName").status(Status.DELETED).tel("010-1111-2222").build(); + } + + @Test + public void signUpTest_라이더_회원가입_성공() { + RiderDTO riderInfo = generateRider(); + when(riderInfoMapper.isExistById(riderInfo.getId())).thenReturn(false); + + riderInfoService.signUp(riderInfo); + } + + @Test(expected = DuplicateException.class) + public void signUpTest_라이더_회원가입_실패_아이디중복() { + RiderDTO riderInfo = generateRider(); + when(riderInfoMapper.isExistById(riderInfo.getId())).thenReturn(true); + + riderInfoService.signUp(riderInfo); + } + + @Test + public void signInTest_라이더_로그인_성공() { + String id = "testId"; + String password = "testPassword"; + String encryptPassword = SHA256Util.encryptSHA256(password); + + when(riderInfoMapper.findByIdAndPassword(id, encryptPassword)).thenReturn(generateRider()); + riderInfoService.signIn(id, password); + } + + @Test(expected = IdDeletedException.class) + public void signInTest_라이더_로그인_실패_삭제된_아이디() { + String id = "testId"; + String password = "testPassword"; + String encryptPassword = SHA256Util.encryptSHA256(password); + + when(riderInfoMapper.findByIdAndPassword(id, encryptPassword)) + .thenReturn(generateDeletedRider()); + riderInfoService.signIn(id, password); + } + + @Test(expected = IllegalArgumentException.class) + public void signInTest_라이더_로그인_실패_비밀번호_불일치() { + String id = "testId"; + String password = "testPassword"; + String encryptPassword = SHA256Util.encryptSHA256(password); + + when(riderInfoMapper.findByIdAndPassword(id, encryptPassword)).thenReturn(null); + riderInfoService.signIn(id, password); + } + + @Test + public void changePasswordTest_라이더_패스워드_변경_성공() { + String id = "testId"; + String passwordBeforeChange = "testPassword"; + String passwordAfterChange = "afterPassword"; + + when(riderInfoMapper.isExistAndEffectiveByIdAndPassword(id, + SHA256Util.encryptSHA256(passwordBeforeChange))).thenReturn(true); + + riderInfoService.changePassword(id, passwordBeforeChange, passwordAfterChange); + } + + @Test(expected = IllegalArgumentException.class) + public void changePasswordTest_라이더_패스워드_변경_실패_패스워드_불일치() { + String id = "testId"; + String passwordBeforeChange = "testPassword"; + String passwordAfterChange = "afterPassword"; + + when(riderInfoMapper.isExistAndEffectiveByIdAndPassword(id, + SHA256Util.encryptSHA256(passwordBeforeChange))).thenReturn(false); + + riderInfoService.changePassword(id, passwordBeforeChange, passwordAfterChange); + } + + @Test + public void deleteAccountTest_라이더_계정_삭제() { + String id = "testId"; + String password = "testPw"; + + when(riderInfoService.isEffective(id, password)).thenReturn(true); + riderInfoService.deleteAccount(id, password); + } + + @Test(expected = IllegalArgumentException.class) + public void deleteAccountTest_라이더_계정_삭제_실패_비밀번호_불일치() { + String id = "testId"; + String password = "testPw"; + + when(riderInfoService.isEffective(id, password)).thenReturn(false); + riderInfoService.deleteAccount(id, password); + } + + @Test + public void changeMailTest_메일주소_변경() { + String id = "testId"; + String password = "testPw"; + String mail = "changeMail@sss.com"; + + when(riderInfoService.isEffective(id, password)).thenReturn(true); + riderInfoService.changeMail(id, password, mail); + } + + @Test(expected = IllegalArgumentException.class) + public void changeMailTest_메일주소_변경_실패_비밀번호_불일치() { + String id = "testId"; + String password = "testPw"; + String mail = "changeMail@sss.com"; + + when(riderInfoService.isEffective(id, password)).thenReturn(false); + riderInfoService.changeMail(id, password, mail); + } +}