diff --git a/scripts/deploy.sh b/scripts/deploy.sh index b865709a..c392efa9 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,5 +1,5 @@ -#!/bin/bash -source /etc/environment +# !/bin/bash +# source /etc/environment BUILD_PATH=$(ls /home/ubuntu/app/server-0.0.1-SNAPSHOT.jar) JAR_NAME=$(basename $BUILD_PATH) @@ -10,12 +10,12 @@ DEPLOY_PATH=/home/ubuntu/app/nonstop/jar/ cp $BUILD_PATH $DEPLOY_PATH echo "> 현재 구동중인 Set 확인" -if [ $DEPLOY_ENV = "main" ]; then - echo $DEPLOY_ENV - CURRENT_PROFILE=$(curl -s https://api.tattour.shop/profile) || { echo "Curl 요청 실패";} -elif [ $DEPLOY_ENV = "dev" ]; then - echo $DEPLOY_ENV - CURRENT_PROFILE=$(curl -s https://dev.tattour.shop/profile) || { echo "Curl 요청 실패";} +if [ "$DEPLOY_ENV" = "main" ]; then + echo "$DEPLOY_ENV" + CURRENT_PROFILE=$(curl -s https://api.tattour.shop/profile) || { echo "Curl 요청 실패"; } +elif [ "$DEPLOY_ENV" = "dev" ]; then + echo "$DEPLOY_ENV" + CURRENT_PROFILE=$(curl -s https://dev.tattour.shop/profile) || { echo "Curl 요청 실패"; } else echo "> DEPLOY_ENV가 설정되지 않았습니다. DEPLOY_ENV: $DEPLOY_ENV" exit 1 @@ -23,12 +23,10 @@ fi echo "> $CURRENT_PROFILE" # 쉬고 있는 set 찾기 -if [ $CURRENT_PROFILE == set1 ] -then +if [ "$CURRENT_PROFILE" = "set1" ]; then IDLE_PROFILE=set2 IDLE_PORT=8082 -elif [ $CURRENT_PROFILE == set2 ] -then +elif [ "$CURRENT_PROFILE" = "set2" ]; then IDLE_PROFILE=set1 IDLE_PORT=8081 else @@ -37,39 +35,34 @@ else IDLE_PROFILE=set1 IDLE_PORT=8081 fi - echo "> application.jar 교체" -IDLE_APPLICATION=$IDLE_PROFILE-Tattour.jar -IDLE_APPLICATION_PATH=$DEPLOY_PATH$IDLE_APPLICATION - -ln -Tfs $DEPLOY_PATH$JAR_NAME $IDLE_APPLICATION_PATH - +IDLE_APPLICATION="$IDLE_PROFILE-Tattour.jar" +IDLE_APPLICATION_PATH="$DEPLOY_PATH$IDLE_APPLICATION" +ln -Tfs "$DEPLOY_PATH$JAR_NAME" "$IDLE_APPLICATION_PATH" echo "> $IDLE_PROFILE 에서 구동중인 애플리케이션 pid 확인" -IDLE_PID=$(pgrep -f $IDLE_APPLICATION) +IDLE_PID=$(pgrep -f "$IDLE_APPLICATION") -if [ -z $IDLE_PID ] -then +if [ -z "$IDLE_PID" ]; then echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." else echo "> kill -15 $IDLE_PID" - kill -15 $IDLE_PID + kill -15 "$IDLE_PID" sleep 5 fi - echo "> $IDLE_PROFILE 배포" echo "> nohup java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=$IDLE_PROFILE $IDLE_APPLICATION_PATH >> /home/ubuntu/app/nohup.out 2>&1 & " -nohup java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=$IDLE_PROFILE $IDLE_APPLICATION_PATH >> /home/ubuntu/app/nohup.out 2>&1 & +nohup java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active="$IDLE_PROFILE" "$IDLE_APPLICATION_PATH" >> /home/ubuntu/app/nohup.out 2>&1 & echo "> $IDLE_PROFILE 10초 후 Health check 시작" echo "> curl -s http://localhost:$IDLE_PORT/actuator/health " sleep 10 -for retry_count in {1..10} +for retry_count in $(seq 1 10) do response=$(curl -s http://localhost:$IDLE_PORT/actuator/health) - up_count=$(echo $response | grep 'UP' | wc -l) + up_count=$(echo "$response" | grep 'UP' | wc -l) - if [ $up_count -ge 1 ] + if [ "$up_count" -ge 1 ] then # $up_count >= 1 ("UP" 문자열이 있는지 검증) echo "> Health check 성공" break @@ -78,13 +71,12 @@ do echo "> Health check: ${response}" fi - if [ $retry_count -eq 10 ] + if [ "$retry_count" -eq 10 ] then echo "> Health check 실패. " echo "> Nginx에 연결하지 않고 배포를 종료합니다." exit 1 fi - echo "> Health check 연결 실패. 재시도..." sleep 10 done diff --git a/server/src/main/generated/org/tattour/server/global/util/EntityDtoMapperImpl.java b/server/src/main/generated/org/tattour/server/global/util/EntityDtoMapperImpl.java index 927cd923..ed4f69c6 100644 --- a/server/src/main/generated/org/tattour/server/global/util/EntityDtoMapperImpl.java +++ b/server/src/main/generated/org/tattour/server/global/util/EntityDtoMapperImpl.java @@ -5,34 +5,34 @@ import javax.annotation.processing.Generated; import org.springframework.data.domain.Page; import org.springframework.stereotype.Component; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; import org.tattour.server.domain.custom.facade.dto.response.CreateCustomSummaryRes; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryRes; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.domain.OrderStatus; +import org.tattour.server.domain.order.model.Order; +import org.tattour.server.domain.order.model.OrderStatus; import org.tattour.server.domain.order.provider.vo.OrderHistoryInfo; import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo; import org.tattour.server.domain.point.domain.PointChargeRequest; import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.provider.vo.StickerLikedInfo; -import org.tattour.server.domain.user.domain.ProductLiked; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.user.model.ProductLiked; +import org.tattour.server.domain.user.model.User; import org.tattour.server.domain.user.provider.vo.HomeUserInfo; import org.tattour.server.domain.user.provider.vo.UserContactInfo; import org.tattour.server.domain.user.provider.vo.UserProfileInfo; @Generated( - value = "org.mapstruct.ap.MappingProcessor", - date = "2023-08-20T21:01:59+0900", - comments = "version: 1.5.4.Final, compiler: javac, environment: Java 17.0.6 (Amazon.com Inc.)" + value = "org.mapstruct.ap.MappingProcessor", + date = "2023-08-20T21:01:59+0900", + comments = "version: 1.5.4.Final, compiler: javac, environment: Java 17.0.6 (Amazon.com Inc.)" ) @Component public class EntityDtoMapperImpl implements EntityDtoMapper { @Override public HomeUserInfo toHomeUserInfo(User user) { - if ( user == null ) { + if (user == null) { return null; } @@ -42,46 +42,46 @@ public HomeUserInfo toHomeUserInfo(User user) { name = user.getName(); point = user.getPoint(); - HomeUserInfo homeUserInfo = new HomeUserInfo( name, point ); + HomeUserInfo homeUserInfo = new HomeUserInfo(name, point); return homeUserInfo; } @Override public UserContactInfo toUserContactInfo(User user) { - if ( user == null ) { + if (user == null) { return null; } UserContactInfo userContactInfo = new UserContactInfo(); - userContactInfo.setId( user.getId() ); - userContactInfo.setName( user.getName() ); - userContactInfo.setPhoneNumber( user.getPhoneNumber() ); + userContactInfo.setId(user.getId()); + userContactInfo.setName(user.getName()); + userContactInfo.setPhoneNumber(user.getPhoneNumber()); return userContactInfo; } @Override public UserProfileInfo toUserProfileInfo(User user) { - if ( user == null ) { + if (user == null) { return null; } UserProfileInfo.UserProfileInfoBuilder userProfileInfo = UserProfileInfo.builder(); - if ( user.getId() != null ) { - userProfileInfo.id( user.getId() ); + if (user.getId() != null) { + userProfileInfo.id(user.getId()); } - userProfileInfo.name( user.getName() ); - userProfileInfo.phoneNumber( user.getPhoneNumber() ); + userProfileInfo.name(user.getName()); + userProfileInfo.phoneNumber(user.getPhoneNumber()); return userProfileInfo.build(); } @Override public StickerLikedInfo toStickerLikedInfo(ProductLiked productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } @@ -91,29 +91,33 @@ public StickerLikedInfo toStickerLikedInfo(ProductLiked productLiked) { String mainImageUrl = null; Integer id = null; - stickerId = productLikedStickerId( productLiked ); - name = productLikedStickerName( productLiked ); - price = productLikedStickerPrice( productLiked ); - mainImageUrl = productLikedStickerMainImageUrl( productLiked ); + stickerId = productLikedStickerId(productLiked); + name = productLikedStickerName(productLiked); + price = productLikedStickerPrice(productLiked); + mainImageUrl = productLikedStickerMainImageUrl(productLiked); id = productLiked.getId(); - Integer discountPrice = productLiked.getSticker().getDiscount() != null ? productLiked.getSticker().getPrice() * (100 - productLiked.getSticker().getDiscount().getDiscountRate()) / 100 : null; - Integer discountRate = productLiked.getSticker().getDiscount() != null ? productLiked.getSticker().getDiscount().getDiscountRate() : null; + Integer discountPrice = productLiked.getSticker().getDiscount() != null ? + productLiked.getSticker().getPrice() * (100 - productLiked.getSticker().getDiscount().getDiscountRate()) + / 100 : null; + Integer discountRate = productLiked.getSticker().getDiscount() != null ? productLiked.getSticker().getDiscount() + .getDiscountRate() : null; - StickerLikedInfo stickerLikedInfo = new StickerLikedInfo( id, stickerId, name, price, discountRate, discountPrice, mainImageUrl ); + StickerLikedInfo stickerLikedInfo = new StickerLikedInfo(id, stickerId, name, price, discountRate, + discountPrice, mainImageUrl); return stickerLikedInfo; } @Override public List toStickerLikedInfoList(List productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } - List list = new ArrayList( productLiked.size() ); - for ( ProductLiked productLiked1 : productLiked ) { - list.add( toStickerLikedInfo( productLiked1 ) ); + List list = new ArrayList(productLiked.size()); + for (ProductLiked productLiked1 : productLiked) { + list.add(toStickerLikedInfo(productLiked1)); } return list; @@ -121,59 +125,59 @@ public List toStickerLikedInfoList(List productL @Override public UserOrderHistoryInfo toGetUserOrderHistoryRes(Order order) { - if ( order == null ) { + if (order == null) { return null; } UserOrderHistoryInfo userOrderHistoryInfo = new UserOrderHistoryInfo(); - Integer id = orderUserId( order ); - if ( id != null ) { - userOrderHistoryInfo.setUserId( id ); + Integer id = orderUserId(order); + if (id != null) { + userOrderHistoryInfo.setUserId(id); } - Integer id1 = orderStickerId( order ); - if ( id1 != null ) { - userOrderHistoryInfo.setStickerId( id1 ); + Integer id1 = orderStickerId(order); + if (id1 != null) { + userOrderHistoryInfo.setStickerId(id1); } - if ( order.getId() != null ) { - userOrderHistoryInfo.setId( order.getId() ); + if (order.getId() != null) { + userOrderHistoryInfo.setId(order.getId()); } - userOrderHistoryInfo.setProductName( order.getProductName() ); - userOrderHistoryInfo.setProductSize( order.getProductSize() ); - userOrderHistoryInfo.setProductImageUrl( order.getProductImageUrl() ); - if ( order.getProductAmount() != null ) { - userOrderHistoryInfo.setProductAmount( order.getProductAmount() ); + userOrderHistoryInfo.setProductName(order.getProductName()); + userOrderHistoryInfo.setProductSize(order.getProductSize()); + userOrderHistoryInfo.setProductImageUrl(order.getProductImageUrl()); + if (order.getProductAmount() != null) { + userOrderHistoryInfo.setProductAmount(order.getProductAmount()); } - if ( order.getProductCount() != null ) { - userOrderHistoryInfo.setProductCount( order.getProductCount() ); + if (order.getProductCount() != null) { + userOrderHistoryInfo.setProductCount(order.getProductCount()); } - if ( order.getShippingFee() != null ) { - userOrderHistoryInfo.setShippingFee( order.getShippingFee() ); + if (order.getShippingFee() != null) { + userOrderHistoryInfo.setShippingFee(order.getShippingFee()); } - if ( order.getTotalAmount() != null ) { - userOrderHistoryInfo.setTotalAmount( order.getTotalAmount() ); + if (order.getTotalAmount() != null) { + userOrderHistoryInfo.setTotalAmount(order.getTotalAmount()); } - userOrderHistoryInfo.setRecipientName( order.getRecipientName() ); - userOrderHistoryInfo.setContact( order.getContact() ); - userOrderHistoryInfo.setMailingAddress( order.getMailingAddress() ); - userOrderHistoryInfo.setBaseAddress( order.getBaseAddress() ); - userOrderHistoryInfo.setDetailAddress( order.getDetailAddress() ); - userOrderHistoryInfo.setCreatedAt( order.getCreatedAt() ); - userOrderHistoryInfo.setLastUpdatedAt( order.getLastUpdatedAt() ); - userOrderHistoryInfo.setState( order.getState() ); + userOrderHistoryInfo.setRecipientName(order.getRecipientName()); + userOrderHistoryInfo.setContact(order.getContact()); + userOrderHistoryInfo.setMailingAddress(order.getMailingAddress()); + userOrderHistoryInfo.setBaseAddress(order.getBaseAddress()); + userOrderHistoryInfo.setDetailAddress(order.getDetailAddress()); + userOrderHistoryInfo.setCreatedAt(order.getCreatedAt()); + userOrderHistoryInfo.setLastUpdatedAt(order.getLastUpdatedAt()); + userOrderHistoryInfo.setState(order.getState()); return userOrderHistoryInfo; } @Override public List toGetUserOrderHistoryListRes(List orderList) { - if ( orderList == null ) { + if (orderList == null) { return null; } - List list = new ArrayList( orderList.size() ); - for ( Order order : orderList ) { - list.add( toGetUserOrderHistoryRes( order ) ); + List list = new ArrayList(orderList.size()); + for (Order order : orderList) { + list.add(toGetUserOrderHistoryRes(order)); } return list; @@ -181,60 +185,60 @@ public List toGetUserOrderHistoryListRes(List order @Override public OrderHistoryInfo toOrderHistoryInfo(Order order) { - if ( order == null ) { + if (order == null) { return null; } OrderHistoryInfo orderHistoryInfo = new OrderHistoryInfo(); - Integer id = orderUserId( order ); - if ( id != null ) { - orderHistoryInfo.setUserId( id ); + Integer id = orderUserId(order); + if (id != null) { + orderHistoryInfo.setUserId(id); } - Integer id1 = orderStickerId( order ); - if ( id1 != null ) { - orderHistoryInfo.setStickerId( id1 ); + Integer id1 = orderStickerId(order); + if (id1 != null) { + orderHistoryInfo.setStickerId(id1); } - orderHistoryInfo.setOrderStatus( orderOrderStatusValue( order ) ); - if ( order.getId() != null ) { - orderHistoryInfo.setId( order.getId() ); + orderHistoryInfo.setOrderStatus(orderOrderStatusValue(order)); + if (order.getId() != null) { + orderHistoryInfo.setId(order.getId()); } - orderHistoryInfo.setProductName( order.getProductName() ); - orderHistoryInfo.setProductSize( order.getProductSize() ); - orderHistoryInfo.setProductImageUrl( order.getProductImageUrl() ); - if ( order.getProductAmount() != null ) { - orderHistoryInfo.setProductAmount( order.getProductAmount() ); + orderHistoryInfo.setProductName(order.getProductName()); + orderHistoryInfo.setProductSize(order.getProductSize()); + orderHistoryInfo.setProductImageUrl(order.getProductImageUrl()); + if (order.getProductAmount() != null) { + orderHistoryInfo.setProductAmount(order.getProductAmount()); } - if ( order.getProductCount() != null ) { - orderHistoryInfo.setProductCount( order.getProductCount() ); + if (order.getProductCount() != null) { + orderHistoryInfo.setProductCount(order.getProductCount()); } - if ( order.getShippingFee() != null ) { - orderHistoryInfo.setShippingFee( order.getShippingFee() ); + if (order.getShippingFee() != null) { + orderHistoryInfo.setShippingFee(order.getShippingFee()); } - if ( order.getTotalAmount() != null ) { - orderHistoryInfo.setTotalAmount( order.getTotalAmount() ); + if (order.getTotalAmount() != null) { + orderHistoryInfo.setTotalAmount(order.getTotalAmount()); } - orderHistoryInfo.setRecipientName( order.getRecipientName() ); - orderHistoryInfo.setContact( order.getContact() ); - orderHistoryInfo.setMailingAddress( order.getMailingAddress() ); - orderHistoryInfo.setBaseAddress( order.getBaseAddress() ); - orderHistoryInfo.setDetailAddress( order.getDetailAddress() ); - orderHistoryInfo.setCreatedAt( order.getCreatedAt() ); - orderHistoryInfo.setLastUpdatedAt( order.getLastUpdatedAt() ); - orderHistoryInfo.setState( order.getState() ); + orderHistoryInfo.setRecipientName(order.getRecipientName()); + orderHistoryInfo.setContact(order.getContact()); + orderHistoryInfo.setMailingAddress(order.getMailingAddress()); + orderHistoryInfo.setBaseAddress(order.getBaseAddress()); + orderHistoryInfo.setDetailAddress(order.getDetailAddress()); + orderHistoryInfo.setCreatedAt(order.getCreatedAt()); + orderHistoryInfo.setLastUpdatedAt(order.getLastUpdatedAt()); + orderHistoryInfo.setState(order.getState()); return orderHistoryInfo; } @Override public List toOrderHistoryInfoPage(Page orderPage) { - if ( orderPage == null ) { + if (orderPage == null) { return null; } List list = new ArrayList(); - for ( Order order : orderPage ) { - list.add( toOrderHistoryInfo( order ) ); + for (Order order : orderPage) { + list.add(toOrderHistoryInfo(order)); } return list; @@ -242,41 +246,42 @@ public List toOrderHistoryInfoPage(Page orderPage) { @Override public PointChargeRequestInfo toGetPointChargeRequestRes(PointChargeRequest pointChargeRequest) { - if ( pointChargeRequest == null ) { + if (pointChargeRequest == null) { return null; } PointChargeRequestInfo.PointChargeRequestInfoBuilder pointChargeRequestInfo = PointChargeRequestInfo.builder(); - Integer id = pointChargeRequestUserId( pointChargeRequest ); - if ( id != null ) { - pointChargeRequestInfo.userId( id ); + Integer id = pointChargeRequestUserId(pointChargeRequest); + if (id != null) { + pointChargeRequestInfo.userId(id); } - if ( pointChargeRequest.getId() != null ) { - pointChargeRequestInfo.id( pointChargeRequest.getId() ); + if (pointChargeRequest.getId() != null) { + pointChargeRequestInfo.id(pointChargeRequest.getId()); } - pointChargeRequestInfo.chargeAmount( pointChargeRequest.getChargeAmount() ); - pointChargeRequestInfo.transferredAmount( pointChargeRequest.getTransferredAmount() ); - pointChargeRequestInfo.isDeposited( pointChargeRequest.getIsDeposited() ); - pointChargeRequestInfo.isAmountMatched( pointChargeRequest.getIsAmountMatched() ); - pointChargeRequestInfo.isApproved( pointChargeRequest.getIsApproved() ); - pointChargeRequestInfo.isCompleted( pointChargeRequest.getIsCompleted() ); - pointChargeRequestInfo.createdAt( pointChargeRequest.getCreatedAt() ); - pointChargeRequestInfo.lastUpdatedAt( pointChargeRequest.getLastUpdatedAt() ); - pointChargeRequestInfo.state( pointChargeRequest.getState() ); + pointChargeRequestInfo.chargeAmount(pointChargeRequest.getChargeAmount()); + pointChargeRequestInfo.transferredAmount(pointChargeRequest.getTransferredAmount()); + pointChargeRequestInfo.isDeposited(pointChargeRequest.getIsDeposited()); + pointChargeRequestInfo.isAmountMatched(pointChargeRequest.getIsAmountMatched()); + pointChargeRequestInfo.isApproved(pointChargeRequest.getIsApproved()); + pointChargeRequestInfo.isCompleted(pointChargeRequest.getIsCompleted()); + pointChargeRequestInfo.createdAt(pointChargeRequest.getCreatedAt()); + pointChargeRequestInfo.lastUpdatedAt(pointChargeRequest.getLastUpdatedAt()); + pointChargeRequestInfo.state(pointChargeRequest.getState()); return pointChargeRequestInfo.build(); } @Override - public List toGetPointChargeRequestResList(List pointChargeRequestList) { - if ( pointChargeRequestList == null ) { + public List toGetPointChargeRequestResList( + List pointChargeRequestList) { + if (pointChargeRequestList == null) { return null; } - List list = new ArrayList( pointChargeRequestList.size() ); - for ( PointChargeRequest pointChargeRequest : pointChargeRequestList ) { - list.add( toGetPointChargeRequestRes( pointChargeRequest ) ); + List list = new ArrayList(pointChargeRequestList.size()); + for (PointChargeRequest pointChargeRequest : pointChargeRequestList) { + list.add(toGetPointChargeRequestRes(pointChargeRequest)); } return list; @@ -284,30 +289,30 @@ public List toGetPointChargeRequestResList(List toCustomApplySummaryInfoList(List customList) { - if ( customList == null ) { + if (customList == null) { return null; } - List list = new ArrayList( customList.size() ); - for ( Custom custom : customList ) { - list.add( toCustomApplySummaryInfo( custom ) ); + List list = new ArrayList(customList.size()); + for (Custom custom : customList) { + list.add(toCustomApplySummaryInfo(custom)); } return list; @@ -315,148 +320,148 @@ public List toCustomApplySummaryInfoList(List cu @Override public ReadCustomSummaryRes toReadCustomSummaryRes(Custom custom) { - if ( custom == null ) { + if (custom == null) { return null; } ReadCustomSummaryRes.ReadCustomSummaryResBuilder readCustomSummaryRes = ReadCustomSummaryRes.builder(); - readCustomSummaryRes.imageUrl( custom.getMainImageUrl() ); - readCustomSummaryRes.id( custom.getId() ); - readCustomSummaryRes.name( custom.getName() ); + readCustomSummaryRes.imageUrl(custom.getMainImageUrl()); + readCustomSummaryRes.id(custom.getId()); + readCustomSummaryRes.name(custom.getName()); return readCustomSummaryRes.build(); } @Override public List toReadCustomSummaryResList(List customList) { - if ( customList == null ) { + if (customList == null) { return null; } - List list = new ArrayList( customList.size() ); - for ( Custom custom : customList ) { - list.add( toReadCustomSummaryRes( custom ) ); + List list = new ArrayList(customList.size()); + for (Custom custom : customList) { + list.add(toReadCustomSummaryRes(custom)); } return list; } private Integer productLikedStickerId(ProductLiked productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } Sticker sticker = productLiked.getSticker(); - if ( sticker == null ) { + if (sticker == null) { return null; } Integer id = sticker.getId(); - if ( id == null ) { + if (id == null) { return null; } return id; } private String productLikedStickerName(ProductLiked productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } Sticker sticker = productLiked.getSticker(); - if ( sticker == null ) { + if (sticker == null) { return null; } String name = sticker.getName(); - if ( name == null ) { + if (name == null) { return null; } return name; } private Integer productLikedStickerPrice(ProductLiked productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } Sticker sticker = productLiked.getSticker(); - if ( sticker == null ) { + if (sticker == null) { return null; } Integer price = sticker.getPrice(); - if ( price == null ) { + if (price == null) { return null; } return price; } private String productLikedStickerMainImageUrl(ProductLiked productLiked) { - if ( productLiked == null ) { + if (productLiked == null) { return null; } Sticker sticker = productLiked.getSticker(); - if ( sticker == null ) { + if (sticker == null) { return null; } String mainImageUrl = sticker.getMainImageUrl(); - if ( mainImageUrl == null ) { + if (mainImageUrl == null) { return null; } return mainImageUrl; } private Integer orderUserId(Order order) { - if ( order == null ) { + if (order == null) { return null; } User user = order.getUser(); - if ( user == null ) { + if (user == null) { return null; } Integer id = user.getId(); - if ( id == null ) { + if (id == null) { return null; } return id; } private Integer orderStickerId(Order order) { - if ( order == null ) { + if (order == null) { return null; } Sticker sticker = order.getSticker(); - if ( sticker == null ) { + if (sticker == null) { return null; } Integer id = sticker.getId(); - if ( id == null ) { + if (id == null) { return null; } return id; } private String orderOrderStatusValue(Order order) { - if ( order == null ) { + if (order == null) { return null; } OrderStatus orderStatus = order.getOrderStatus(); - if ( orderStatus == null ) { + if (orderStatus == null) { return null; } String value = orderStatus.getValue(); - if ( value == null ) { + if (value == null) { return null; } return value; } private Integer pointChargeRequestUserId(PointChargeRequest pointChargeRequest) { - if ( pointChargeRequest == null ) { + if (pointChargeRequest == null) { return null; } User user = pointChargeRequest.getUser(); - if ( user == null ) { + if (user == null) { return null; } Integer id = user.getId(); - if ( id == null ) { + if (id == null) { return null; } return id; diff --git a/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java b/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java index e97ebba3..e201575b 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java +++ b/server/src/main/java/org/tattour/server/domain/admin/controller/AdminController.java @@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; -import java.util.Objects; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import lombok.RequiredArgsConstructor; @@ -27,8 +26,6 @@ import org.springframework.web.multipart.MultipartFile; import org.tattour.server.domain.admin.controller.dto.request.AdminLoginReq; import org.tattour.server.domain.admin.controller.dto.request.ApplyStickerDiscountReq; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.admin.controller.dto.request.ConfirmPointChargeRequestReq; import org.tattour.server.domain.admin.controller.dto.request.PatchCustomProcessReq; import org.tattour.server.domain.admin.controller.dto.request.PostDiscountReq; import org.tattour.server.domain.admin.controller.dto.request.PostStickerReq; @@ -41,17 +38,9 @@ import org.tattour.server.domain.order.controller.dto.request.PatchOrderStatusReq; import org.tattour.server.domain.order.facade.OrderFacade; import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.facade.PointFacade; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; +import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes; import org.tattour.server.domain.sticker.facade.StickerFacade; import org.tattour.server.domain.sticker.facade.dto.response.ReadStickerRes; -import org.tattour.server.domain.user.controller.dto.response.PostLoginRes; import org.tattour.server.global.config.annotations.UserId; import org.tattour.server.global.dto.BaseResponse; import org.tattour.server.global.dto.FailResponse; @@ -66,7 +55,6 @@ public class AdminController { private final AdminFacade adminFacade; - private final PointFacade pointFacade; private final OrderFacade orderFacade; private final DiscountFacade discountFacade; private final StickerFacade stickerFacade; @@ -97,7 +85,7 @@ public ResponseEntity adminLogin( @ApiResponse( responseCode = "200", description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = PostLoginRes.class))), + content = @Content(schema = @Schema(implementation = ReadOrderHistoryListRes.class))), @ApiResponse( responseCode = "400", description = "잘못된 요청입니다.", @@ -151,149 +139,7 @@ public ResponseEntity patchOrderStatus( return BaseResponse.success(SuccessType.UPDATE_ORDER_STATUS_SUCCESS); } - - @Operation(summary = "포인트 충전 신청 내역 불러오기", description = "userId, 완료 여부를 기준으로 포인트 신청 내역 조회") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadPointChargeRequestListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/point/request") - public ResponseEntity getPointChargeRequest( - @Parameter(description = "user Id") @RequestParam(required = false) Integer userId, - @Parameter(description = "처리 완료 여부") @RequestParam(required = false) Boolean isCompleted - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, - pointFacade.readPointChargeRequest( - ReadPointChargeRequestListReq.of( - userId, - isCompleted))); - } - - @Operation(summary = "포인트 충전 요청 확인") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "포인트 충전 확정에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "202", - description = "금액이 일치하지 않아 충전 확정이 불가능합니다.", - content = @Content(schema = @Schema(implementation = ConfirmPointChargeRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "이미 처리된 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/point/request/confirm") - public ResponseEntity confirmPointChargeRequest( - @RequestBody @Valid ConfirmPointChargeRequestReq req - ) { - ConfirmPointChargeRes response = pointFacade.confirmPointChargeRequest( - ConfirmPointChargeReq.of( - req.getId(), - req.getUserId(), - req.getTransferredAmount())); - - if (Objects.isNull(response)) { - return BaseResponse.success(SuccessType.POINT_CHARGE_CONFIRM_SUCCESS); - } else { - return BaseResponse.success(SuccessType.POINT_CHARGE_CONFIRM_FAIL, response); - } - } - - @Operation(summary = "포인트 충전 요청 취소") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "포인트 충전 취소에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "이미 처리된 포인트 충전 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "409", - description = "송금 금액과 충전 금액이 일치합니다. 충전 요청을 취소할 수 없습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping("/point/request/cancel") - public ResponseEntity cancelPointChargeRequest( - @RequestBody @Valid CancelPointChargeRequestReq req - ) { - pointFacade.cancelPointChargeRequest(req); - return BaseResponse.success(SuccessType.POINT_CHARGE_CANCEL_SUCCESS); - } - - @Operation(summary = "포인트 로그 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "포인트 로그 조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadPointLogListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/pointlog") - public ResponseEntity getPointLog( - @Parameter(description = "user id") @RequestParam(required = false) Integer userId, - @Parameter(description = "포인트 로그 카테고리", example = "충전 취소") - @RequestParam(required = false) String category - ) { - return BaseResponse.success( - SuccessType.READ_POINT_LOG_SUCCESS, pointFacade.readPointLog( - ReadPointLogListReq.of( - userId, - PointLogCategory.fromValue(category)))); - } - + @PostMapping(value = "/stickers", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "스티커 등록") @ApiResponses(value = { diff --git a/server/src/main/java/org/tattour/server/domain/admin/controller/dto/request/PatchCustomProcessReq.java b/server/src/main/java/org/tattour/server/domain/admin/controller/dto/request/PatchCustomProcessReq.java index a888ff72..dc90e334 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/controller/dto/request/PatchCustomProcessReq.java +++ b/server/src/main/java/org/tattour/server/domain/admin/controller/dto/request/PatchCustomProcessReq.java @@ -4,7 +4,7 @@ import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; -import org.tattour.server.domain.custom.domain.CustomProcess; +import org.tattour.server.domain.custom.model.CustomProcess; import org.tattour.server.domain.custom.facade.dto.request.UpdateCustomReq; @Getter diff --git a/server/src/main/java/org/tattour/server/domain/admin/facade/impl/AdminFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/admin/facade/impl/AdminFacadeImpl.java index 6b991981..113ea3a9 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/facade/impl/AdminFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/admin/facade/impl/AdminFacadeImpl.java @@ -5,10 +5,10 @@ import org.springframework.transaction.annotation.Transactional; import org.tattour.server.domain.admin.controller.dto.request.AdminLoginReq; import org.tattour.server.domain.admin.controller.dto.response.AdminLoginRes; -import org.tattour.server.domain.admin.domain.Admin; import org.tattour.server.domain.admin.facade.AdminFacade; +import org.tattour.server.domain.admin.model.Admin; import org.tattour.server.domain.admin.service.AdminService; -import org.tattour.server.domain.user.domain.UserRole; +import org.tattour.server.domain.user.model.UserRole; import org.tattour.server.global.config.jwt.JwtService; import org.tattour.server.global.exception.BusinessException; import org.tattour.server.global.exception.ErrorType; diff --git a/server/src/main/java/org/tattour/server/domain/admin/domain/Admin.java b/server/src/main/java/org/tattour/server/domain/admin/model/Admin.java similarity index 94% rename from server/src/main/java/org/tattour/server/domain/admin/domain/Admin.java rename to server/src/main/java/org/tattour/server/domain/admin/model/Admin.java index 0a404774..fa501f30 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/domain/Admin.java +++ b/server/src/main/java/org/tattour/server/domain/admin/model/Admin.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.admin.domain; +package org.tattour.server.domain.admin.model; import java.sql.Timestamp; import javax.persistence.Column; diff --git a/server/src/main/java/org/tattour/server/domain/admin/domain/AdminAccessLog.java b/server/src/main/java/org/tattour/server/domain/admin/model/AdminAccessLog.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/admin/domain/AdminAccessLog.java rename to server/src/main/java/org/tattour/server/domain/admin/model/AdminAccessLog.java index ef8fa8df..123b7ecb 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/domain/AdminAccessLog.java +++ b/server/src/main/java/org/tattour/server/domain/admin/model/AdminAccessLog.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.admin.domain; +package org.tattour.server.domain.admin.model; import java.sql.Timestamp; import javax.persistence.Entity; diff --git a/server/src/main/java/org/tattour/server/domain/admin/repository/AdminAccessLogRepository.java b/server/src/main/java/org/tattour/server/domain/admin/repository/AdminAccessLogRepository.java index 42dad336..ece522a7 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/repository/AdminAccessLogRepository.java +++ b/server/src/main/java/org/tattour/server/domain/admin/repository/AdminAccessLogRepository.java @@ -2,7 +2,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import org.tattour.server.domain.admin.domain.AdminAccessLog; +import org.tattour.server.domain.admin.model.AdminAccessLog; @Repository public interface AdminAccessLogRepository extends JpaRepository { diff --git a/server/src/main/java/org/tattour/server/domain/admin/repository/AdminRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/admin/repository/AdminRepositoryImpl.java index f581f22b..f068bb59 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/repository/AdminRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/admin/repository/AdminRepositoryImpl.java @@ -3,7 +3,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import org.tattour.server.domain.admin.domain.Admin; +import org.tattour.server.domain.admin.model.Admin; @Repository public interface AdminRepositoryImpl extends JpaRepository { diff --git a/server/src/main/java/org/tattour/server/domain/admin/service/AdminService.java b/server/src/main/java/org/tattour/server/domain/admin/service/AdminService.java index c95f86ea..9cf2aad2 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/service/AdminService.java +++ b/server/src/main/java/org/tattour/server/domain/admin/service/AdminService.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.admin.service; -import org.tattour.server.domain.admin.domain.Admin; +import org.tattour.server.domain.admin.model.Admin; public interface AdminService { diff --git a/server/src/main/java/org/tattour/server/domain/admin/service/impl/AdminServiceImpl.java b/server/src/main/java/org/tattour/server/domain/admin/service/impl/AdminServiceImpl.java index 9376d029..e60fbdda 100644 --- a/server/src/main/java/org/tattour/server/domain/admin/service/impl/AdminServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/admin/service/impl/AdminServiceImpl.java @@ -3,8 +3,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; -import org.tattour.server.domain.admin.domain.Admin; -import org.tattour.server.domain.admin.domain.AdminAccessLog; +import org.tattour.server.domain.admin.model.Admin; +import org.tattour.server.domain.admin.model.AdminAccessLog; import org.tattour.server.domain.admin.repository.AdminAccessLogRepository; import org.tattour.server.domain.admin.repository.AdminRepositoryImpl; import org.tattour.server.domain.admin.service.AdminService; diff --git a/server/src/main/java/org/tattour/server/domain/banner/domain/Banner.java b/server/src/main/java/org/tattour/server/domain/banner/model/Banner.java similarity index 93% rename from server/src/main/java/org/tattour/server/domain/banner/domain/Banner.java rename to server/src/main/java/org/tattour/server/domain/banner/model/Banner.java index cd78c834..8a947975 100644 --- a/server/src/main/java/org/tattour/server/domain/banner/domain/Banner.java +++ b/server/src/main/java/org/tattour/server/domain/banner/model/Banner.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.banner.domain; +package org.tattour.server.domain.banner.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/CartController.java b/server/src/main/java/org/tattour/server/domain/cart/controller/CartController.java new file mode 100644 index 00000000..f9802c11 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/CartController.java @@ -0,0 +1,152 @@ +package org.tattour.server.domain.cart.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import javax.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.tattour.server.domain.cart.controller.dto.request.CartItemReq; +import org.tattour.server.domain.cart.controller.dto.request.UpdateCartCountReq; +import org.tattour.server.domain.cart.controller.dto.response.CartItemsRes; +import org.tattour.server.domain.cart.facade.CartFacade; +import org.tattour.server.global.config.annotations.UserId; +import org.tattour.server.global.dto.BaseResponse; +import org.tattour.server.global.dto.FailResponse; +import org.tattour.server.global.dto.SuccessResponse; +import org.tattour.server.global.dto.SuccessType; + +@RestController +@RequestMapping("/api/v1/cart") +@SecurityRequirement(name = "JWT Auth") +@Tag(name = "Cart", description = "Cart API Document") +@RequiredArgsConstructor +@Validated +public class CartController { + + private final CartFacade cartFacade; + + @Operation(summary = "장바구니 아이템 추가") + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "생성에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 스티커입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PostMapping + public ResponseEntity saveCartItem( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid CartItemReq cartItemReq + ) { + cartFacade.saveCartItem(userId, cartItemReq); + return BaseResponse.success(SuccessType.CREATE_SUCCESS); + } + + @Operation(summary = "유저 장바구니 목록 조회") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "조회에 성공했습니다.", + content = @Content(schema = @Schema(implementation = CartItemsRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping + public ResponseEntity getUserCartItem( + @Parameter(hidden = true) @UserId Integer userId + ) { + return BaseResponse.success(SuccessType.GET_SUCCESS, cartFacade.getUserCartItems(userId)); + } + + @Operation(summary = "장바구니 수량 일괄 수정") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "갱신에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 장바구니입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PatchMapping + public ResponseEntity updateCartCount( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid UpdateCartCountReq req) { + cartFacade.updateCartsCount(userId, req); + return BaseResponse.success(SuccessType.UPDATE_SUCCESS); + } + + @Operation(summary = "장바구니 삭제") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "삭제에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 장바구니입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @DeleteMapping("/{cartId}") + public ResponseEntity deleteCartCount( + @Parameter(hidden = true) @UserId Integer userId, + @Parameter(description = "장바구니 Id") @PathVariable Integer cartId) { + cartFacade.deleteCartItem(userId, cartId); + return BaseResponse.success(SuccessType.DELETE_SUCCESS); + } +} + + diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartCountReq.java b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartCountReq.java new file mode 100644 index 00000000..1ece0057 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartCountReq.java @@ -0,0 +1,17 @@ +package org.tattour.server.domain.cart.controller.dto.request; + +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.NotNull; +import lombok.Getter; + +@Schema(description = "장바구니 수량 수정 Request") +@Getter +public class CartCountReq { + @Schema(description = "장바구니 Id") + @NotNull(message = "장바구니 id는 null일 수 없습니다.") + private int cartId; + + @Schema(description = "장바구니 수량") + @NotNull(message = "장바구니 수량 null일 수 없습니다.") + private int count; +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartItemReq.java b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartItemReq.java new file mode 100644 index 00000000..83332452 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/CartItemReq.java @@ -0,0 +1,20 @@ +package org.tattour.server.domain.cart.controller.dto.request; + +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class CartItemReq { + @Schema(description = "스티커 Id") + @NotNull + private int stickerId; + + @Schema(description = "스티커 수량") + @NotNull + @Min(1) + private int count; +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/UpdateCartCountReq.java b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/UpdateCartCountReq.java new file mode 100644 index 00000000..e11f0ad1 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/request/UpdateCartCountReq.java @@ -0,0 +1,12 @@ +package org.tattour.server.domain.cart.controller.dto.request; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import lombok.Getter; + +@Schema(description = "장바구니 수량 일괄 수정 Request") +@Getter +public class UpdateCartCountReq { + @Schema(description = "장바구니 수량 수정 Request 목록") + private List cartCountReqs; +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemRes.java b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemRes.java new file mode 100644 index 00000000..4843b68d --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemRes.java @@ -0,0 +1,16 @@ +package org.tattour.server.domain.cart.controller.dto.response; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CartItemRes { + private int id; + private int stickerId; + private String mainImageUrl; + private String name; + private int price; + private int discountPrice; + private int count; +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemsRes.java b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemsRes.java new file mode 100644 index 00000000..ba1471b3 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/controller/dto/response/CartItemsRes.java @@ -0,0 +1,20 @@ +package org.tattour.server.domain.cart.controller.dto.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import org.tattour.server.domain.order.provider.vo.OrderAmountDetailRes; + +@Getter +@Setter +@AllArgsConstructor +public class CartItemsRes { + private List cartItemsRes; + + private OrderAmountDetailRes orderAmountDetailRes; + + public static CartItemsRes of(List cartItemsRes, OrderAmountDetailRes orderAmountDetailRes) { + return new CartItemsRes(cartItemsRes, orderAmountDetailRes); + } +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/facade/CartFacade.java b/server/src/main/java/org/tattour/server/domain/cart/facade/CartFacade.java new file mode 100644 index 00000000..f5937661 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/facade/CartFacade.java @@ -0,0 +1,15 @@ +package org.tattour.server.domain.cart.facade; + +import org.tattour.server.domain.cart.controller.dto.request.CartItemReq; +import org.tattour.server.domain.cart.controller.dto.request.UpdateCartCountReq; +import org.tattour.server.domain.cart.controller.dto.response.CartItemsRes; + +public interface CartFacade { + void saveCartItem(int userId, CartItemReq req); + + CartItemsRes getUserCartItems(int userId); + + void updateCartsCount(int userId, UpdateCartCountReq req); + + void deleteCartItem(int userId, int cartId); +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/facade/impl/CartFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/cart/facade/impl/CartFacadeImpl.java new file mode 100644 index 00000000..a0970e06 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/facade/impl/CartFacadeImpl.java @@ -0,0 +1,65 @@ +package org.tattour.server.domain.cart.facade.impl; + +import static org.tattour.server.domain.order.facade.impl.OrderFacadeImpl.SHIPPING_FEE; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.tattour.server.domain.cart.controller.dto.request.CartItemReq; +import org.tattour.server.domain.cart.controller.dto.request.UpdateCartCountReq; +import org.tattour.server.domain.cart.controller.dto.response.CartItemsRes; +import org.tattour.server.domain.cart.facade.CartFacade; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.cart.service.CartService; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.sticker.provider.StickerProvider; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; +import org.tattour.server.domain.user.model.User; +import org.tattour.server.domain.user.service.UserService; +import org.tattour.server.global.util.EntityDtoMapper; + +@Service +@RequiredArgsConstructor +public class CartFacadeImpl implements CartFacade { + private final CartService cartService; + private final UserService userService; + private final StickerProvider stickerProvider; + + @Override + @Transactional + public void saveCartItem(int userId, CartItemReq req) { + User user = userService.readUserById(userId); + Sticker sticker = stickerProvider.getById(req.getStickerId()); + + cartService.mergeOrAddToCart(user, sticker, req.getCount()); + } + + //todo : 배송 지역별 배송비 책정 + @Override + @Transactional(readOnly = true) + public CartItemsRes getUserCartItems(int userId) { + List carts = cartService.findByUserId(userId); + StickerOrderInfo stickerOrderInfo = stickerProvider.getStickerOrderInfoFromCart(carts); + + return CartItemsRes.of( + EntityDtoMapper.INSTANCE.toCartItemsRes(carts), + EntityDtoMapper.INSTANCE.toOrderAmountRes(stickerOrderInfo, SHIPPING_FEE)); + } + + @Override + @Transactional + public void updateCartsCount(int userId, UpdateCartCountReq updateCartCountReq) { + updateCartCountReq.getCartCountReqs() + .forEach(req -> cartService + .findByIdAndUserId(req.getCartId(), userId) + .updateCount(req.getCount())); + } + + @Override + @Transactional + public void deleteCartItem(int userId, int cartId) { + Cart cart = cartService.findByIdAndUserId(cartId, userId); + cartService.delete(cart); + } +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/cart/model/Cart.java b/server/src/main/java/org/tattour/server/domain/cart/model/Cart.java new file mode 100644 index 00000000..68d6150d --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/model/Cart.java @@ -0,0 +1,46 @@ +package org.tattour.server.domain.cart.model; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.user.model.User; + +@Entity +@Builder +@Getter +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class Cart { + private final static int COUNT_INCREMENT = 1; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + private Integer count; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "sticker_id") + private Sticker sticker; + + public void addCount(int count) { + this.count += count; + } + + public void updateCount(int count) { + this.count = count; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/cart/repository/CartRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/cart/repository/CartRepositoryImpl.java new file mode 100644 index 00000000..170df17e --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/repository/CartRepositoryImpl.java @@ -0,0 +1,22 @@ +package org.tattour.server.domain.cart.repository; + +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.user.model.User; + +@Repository +public interface CartRepositoryImpl extends JpaRepository { + List findByUser_Id(int userId); + + List findByUser(User user); + + Optional findByIdAndUser_Id(int id, int userId); + + Optional findCartByUserAndSticker(User user, Sticker sticker); + + void deleteAllByUser(User user); +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/cart/service/CartService.java b/server/src/main/java/org/tattour/server/domain/cart/service/CartService.java new file mode 100644 index 00000000..b67bb46f --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/service/CartService.java @@ -0,0 +1,25 @@ +package org.tattour.server.domain.cart.service; + +import java.util.List; +import java.util.Optional; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.user.model.User; + +public interface CartService { + List findByUserId(int userId); + + List findByUser(User user); + + Optional findByUserAndSticker(User user, Sticker sticker); + + Cart findByIdAndUserId(int id, int userId); + + void mergeOrAddToCart(User user, Sticker sticker, int count); + + Cart createNewCart(User user, Sticker sticker, int count); + + void delete(Cart cart); + + void deleteAllByUserId(User user); +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/cart/service/impl/CartServiceImpl.java b/server/src/main/java/org/tattour/server/domain/cart/service/impl/CartServiceImpl.java new file mode 100644 index 00000000..10933b12 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/cart/service/impl/CartServiceImpl.java @@ -0,0 +1,70 @@ +package org.tattour.server.domain.cart.service.impl; + +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.cart.repository.CartRepositoryImpl; +import org.tattour.server.domain.cart.service.CartService; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.user.model.User; +import org.tattour.server.global.exception.BusinessException; +import org.tattour.server.global.exception.ErrorType; + +@Service +@RequiredArgsConstructor +public class CartServiceImpl implements CartService { + private final CartRepositoryImpl cartRepositoryImpl; + + @Override + public List findByUserId(int userId) { + return cartRepositoryImpl.findByUser_Id(userId); + } + + @Override + public List findByUser(User user) { + return cartRepositoryImpl.findByUser(user); + } + + @Override + public Optional findByUserAndSticker(User user, Sticker sticker) { + return cartRepositoryImpl.findCartByUserAndSticker(user, sticker); + } + + @Override + public Cart findByIdAndUserId(int id, int userId) { + return cartRepositoryImpl.findByIdAndUser_Id(id, userId) + .orElseThrow(() -> new BusinessException(ErrorType.NOT_FOUND_CART_EXCEPTION)); + } + + @Override + public void mergeOrAddToCart(User user, Sticker sticker, int count) { + Cart cart = findByUserAndSticker(user, sticker) + .map(cartExisting -> { + cartExisting.addCount(count); + return cartExisting; + }) + .orElseGet(() -> createNewCart(user, sticker, count)); + cartRepositoryImpl.save(cart); + } + + @Override + public Cart createNewCart(User user, Sticker sticker, int count) { + return Cart.builder() + .count(count) + .user(user) + .sticker(sticker) + .build(); + } + + @Override + public void delete(Cart cart) { + cartRepositoryImpl.delete(cart); + } + + @Override + public void deleteAllByUserId(User user) { + cartRepositoryImpl.deleteAllByUser(user); + } +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java b/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java index 3f3a9f0b..30ba5b72 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java +++ b/server/src/main/java/org/tattour/server/domain/custom/controller/CustomController.java @@ -21,8 +21,8 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import org.tattour.server.domain.custom.controller.dto.request.PostCustomReq; import org.tattour.server.domain.custom.controller.dto.request.PatchCustomReq; +import org.tattour.server.domain.custom.controller.dto.request.PostCustomReq; import org.tattour.server.domain.custom.controller.dto.response.PatchCustomRes; import org.tattour.server.domain.custom.controller.dto.response.PostCustomRes; import org.tattour.server.domain.custom.facade.CustomFacade; @@ -39,49 +39,48 @@ @Tag(name = "Custom", description = "Custom API Document") public class CustomController { - private final CustomFacade customFacade; + private final CustomFacade customFacade; + + @PostMapping(value = "/apply") + @Operation(summary = "커스텀 도안 신청") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "success", + content = @Content(schema = @Schema(implementation = PostCustomRes.class))), + @ApiResponse(responseCode = "400, 500", description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity postCustom( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid PostCustomReq request + ) { + PostCustomRes response = PostCustomRes.from( + (customFacade.createCustom(request.getHaveDesign(), userId))); + return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response); + } - @PostMapping(value = "/apply") - @Operation(summary = "커스텀 도안 신청") - @ApiResponses(value = { - @ApiResponse(responseCode = "201", description = "success", - content = @Content(schema = @Schema(implementation = PostCustomRes.class))), - @ApiResponse(responseCode = "400, 500", description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity postCustom( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostCustomReq request - ) { - PostCustomRes response = PostCustomRes.from( - (customFacade.createCustom(request.getHaveDesign(), userId))); - return BaseResponse.success(SuccessType.CREATE_CUSTOM_SUCCESS, response); - } + // todo: 클라이언트에서 customInfo의 content-type을 application/json으로 설정해줘야함 + @PatchMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "커스텀 도안 수정", description = "customInfo ContentType: application/json" + + " / customId 를 제외한 모든 컬럼 null 값 가능" + + " / size : " + + " / 테마, 스타일 타입은 Integer") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "success", + content = @Content(schema = @Schema(implementation = PatchCustomRes.class))), + @ApiResponse(responseCode = "400, 500", description = "error", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + public ResponseEntity patchCustom( + @Parameter(hidden = true) @UserId Integer userId, + @RequestPart @Valid PatchCustomReq customInfo, + @RequestPart(required = false) MultipartFile handDrawingImage, + @RequestPart(required = false) List customImages + ) { + PatchCustomRes response = + PatchCustomRes.from( + customFacade.updateCustom( + customInfo.newUpdateCustomReq(userId, customImages, handDrawingImage))); - @PatchMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "커스텀 도안 수정", description = "customInfo ContentType: application/json" - + " / customId 를 제외한 모든 컬럼 null 값 가능" - + " / size : " - + " / 테마, 스타일 타입은 Integer") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "success", - content = @Content(schema = @Schema(implementation = PatchCustomRes.class))), - @ApiResponse(responseCode = "400, 500", description = "error", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - public ResponseEntity patchCustom( - @Parameter(hidden = true) @UserId Integer userId, - @RequestPart @Valid PatchCustomReq customInfo, - @RequestPart(required = false) MultipartFile handDrawingImage, - @RequestPart(required = false) List customImages - ) { - PatchCustomRes response = - PatchCustomRes.from( - customFacade.updateCustom( - customInfo.newUpdateCustomReq( - userId, - customImages, - handDrawingImage))); - return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response); - } + return BaseResponse.success(SuccessType.UPDATE_CUSTOM_SUCCESS, response); + } } \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/request/UpdateCustomReq.java b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/request/UpdateCustomReq.java index 100dfee5..0fb23c05 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/request/UpdateCustomReq.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/request/UpdateCustomReq.java @@ -5,9 +5,9 @@ import lombok.Builder; import lombok.Getter; import org.springframework.web.multipart.MultipartFile; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomProcess; -import org.tattour.server.domain.custom.domain.CustomSize; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomProcess; +import org.tattour.server.domain.custom.model.CustomSize; @Getter @Builder(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java index ebc5fd4d..42ae1b08 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomRes.java @@ -6,105 +6,96 @@ import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomImage; @Getter @Builder(access = AccessLevel.PRIVATE) public class ReadCustomRes { - private Integer id; - private Integer userId; - private Integer stickerId; - private List themes; - private List styles; - private String mainImageUrl; - private String handDrawingImageUrl; - private List images; - private Boolean haveDesign; - private String size; - private String name; - private String description; - private String demand; - private Integer count; - private Boolean isColored; - private Boolean isPublic; - private Boolean isCompleted; - private Integer price; - private String process; - private Integer viewCount; + private Integer id; + private Integer userId; + private Integer stickerId; + private List themes; + private List styles; + private String mainImageUrl; + private String handDrawingImageUrl; + private List images; + private Boolean haveDesign; + private String size; + private String name; + private String description; + private String demand; + private Integer count; + private Boolean isColored; + private Boolean isPublic; + private Boolean isCompleted; + private Integer price; + private String process; + private Integer viewCount; - public static ReadCustomRes from(Custom custom) { - List themes = getThemeNameList(custom); - List styles = getStyleList(custom); - List images = getImageList(custom); - return ReadCustomRes.builder() - .id(custom.getId()) - .userId(custom.getUser().getId()) - .themes(themes) - .styles(styles) - .mainImageUrl(custom.getMainImageUrl()) - .images(images) - .handDrawingImageUrl(custom.getHandDrawingImageUrl()) - .haveDesign(custom.getHaveDesign()) - .size(getSizeString(custom)) - .name(custom.getName()) - .description(custom.getDescription()) - .demand(custom.getDemand()) - .count(custom.getCount()) - .isColored(custom.getIsColored()) - .isPublic(custom.getIsPublic()) - .isCompleted(custom.getIsCompleted()) - .price(custom.getPrice()) - .process(getProcessString(custom)) - .viewCount(custom.getViewCount()) - .build(); - } - // Todo : 주석 지우기 + public static ReadCustomRes from(Custom custom) { + List themes = getThemeNameList(custom); + List styles = getStyleList(custom); + List images = getImageList(custom); + return ReadCustomRes.builder() + .id(custom.getId()) + .userId(custom.getUser().getId()) + .themes(themes) + .styles(styles) + .mainImageUrl(custom.getMainImageUrl()) + .images(images) + .handDrawingImageUrl(custom.getHandDrawingImageUrl()) + .haveDesign(custom.getHaveDesign()) + .size(getSizeString(custom)) + .name(custom.getName()) + .description(custom.getDescription()) + .demand(custom.getDemand()) + .count(custom.getCount()) + .isColored(custom.getIsColored()) + .isPublic(custom.getIsPublic()) + .isCompleted(custom.getIsCompleted()) + .price(custom.getPrice()) + .process(getProcessString(custom)) + .viewCount(custom.getViewCount()) + .build(); + } - private static List getImageList(Custom custom) { -// if (Objects.isNull(custom.getImages())) { -// return null; -// } - return custom - .getImages() - .stream() - .map(customImage -> customImage.getImageUrl()) - .collect(Collectors.toList()); - } + private static List getImageList(Custom custom) { + return custom + .getImages() + .stream() + .map(CustomImage::getImageUrl) + .collect(Collectors.toList()); + } - private static List getStyleList(Custom custom) { -// if (Objects.isNull(custom.getCustomStyles())) { -// return null; -// } - return custom - .getCustomStyles() - .stream() - .map(customStyle -> customStyle.getStyle().getName()) - .collect(Collectors.toList()); - } + private static List getStyleList(Custom custom) { + return custom + .getCustomStyles() + .stream() + .map(customStyle -> customStyle.getStyle().getName()) + .collect(Collectors.toList()); + } - private static List getThemeNameList(Custom custom) { -// if (Objects.isNull(custom.getCustomThemes())) { -// return null; -// } - return custom - .getCustomThemes() - .stream() - .map(customTheme -> customTheme.getTheme().getName()) - .collect(Collectors.toList()); - } + private static List getThemeNameList(Custom custom) { + return custom + .getCustomThemes() + .stream() + .map(customTheme -> customTheme.getTheme().getName()) + .collect(Collectors.toList()); + } - private static String getSizeString(Custom custom) { - if (Objects.isNull(custom.getSize())) { - return null; - } - return custom.getSize().getSize(); - } + private static String getSizeString(Custom custom) { + if (Objects.isNull(custom.getSize())) { + return null; + } + return custom.getSize().getSize(); + } - private static String getProcessString(Custom custom) { - if (Objects.isNull(custom.getProcess())) { - return null; - } - return custom.getProcess().getValue(); - } + private static String getProcessString(Custom custom) { + if (Objects.isNull(custom.getProcess())) { + return null; + } + return custom.getProcess().getValue(); + } } \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryListRes.java b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryListRes.java index b225cbb1..bb8dc0f8 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryListRes.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryListRes.java @@ -5,7 +5,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryRes.java b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryRes.java index 78ef84ac..7e5e30b0 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryRes.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/dto/response/ReadCustomSummaryRes.java @@ -2,7 +2,7 @@ import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; @Getter @Builder diff --git a/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java index b7595940..d46dba54 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/facade/impl/CustomFacadeImpl.java @@ -7,24 +7,19 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomImage; import org.tattour.server.domain.custom.facade.CustomFacade; import org.tattour.server.domain.custom.facade.dto.request.UpdateCustomReq; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomRes; import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomImage; +import org.tattour.server.domain.custom.provider.impl.CustomProviderImpl; import org.tattour.server.domain.custom.service.CustomImageService; import org.tattour.server.domain.custom.service.CustomService; import org.tattour.server.domain.custom.service.CustomStyleService; import org.tattour.server.domain.custom.service.CustomThemeService; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.custom.provider.impl.CustomProviderImpl; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.user.model.User; import org.tattour.server.domain.user.service.UserService; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; import org.tattour.server.infra.discord.service.DiscordMessageService; import org.tattour.server.infra.s3.S3Service; @@ -33,124 +28,110 @@ @RequiredArgsConstructor public class CustomFacadeImpl implements CustomFacade { - private final CustomService customService; - private final CustomImageService customImageService; - private final CustomThemeService customThemeService; - private final CustomStyleService customStyleService; - private final UserService userService; - private final PointService pointService; - private final S3Service s3Service; - private final DiscordMessageService discordMessageService; - private final CustomProviderImpl customProvider; + private final CustomService customService; + private final CustomImageService customImageService; + private final CustomThemeService customThemeService; + private final CustomStyleService customStyleService; + private final UserService userService; + private final S3Service s3Service; + private final DiscordMessageService discordMessageService; + private final CustomProviderImpl customProvider; - private static final String directoryPath = "custom"; - private static final Integer customPoint = 990; + private static final String directoryPath = "custom"; - @Override - @Transactional - public Integer createCustom(Boolean haveDesign, Integer userId) { - User user = userService.readUserById(userId); - if (user.isLackOfPoint(customPoint)) { - throw new BusinessException(ErrorType.LACK_OF_POINT_EXCEPTION); - } - userService.updateUserPoint(user, -customPoint); - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.APPLY_CUSTOM, - "커스텀 스티커 신청", - customPoint, - user.getPoint(), - user)); - Custom custom = customService.createInitCustom(user, haveDesign); - customService.save(custom); - return custom.getId(); - } + @Override + @Transactional + public Integer createCustom(Boolean haveDesign, Integer userId) { + User user = userService.readUserById(userId); + Custom custom = customService.createInitCustom(user, haveDesign); + customService.save(custom); + return custom.getId(); + } - @Override - public ReadCustomRes readCustomById(Integer customId, Integer userId) { - Custom custom = customProvider.getCustomById(customId, userId); - return ReadCustomRes.from(custom); - } + @Override + public ReadCustomRes readCustomById(Integer customId, Integer userId) { + Custom custom = customProvider.getCustomById(customId, userId); + return ReadCustomRes.from(custom); + } - @Override - @Transactional(readOnly = true) - public ReadCustomSummaryListRes readCustomSummaryCompleteListByUserId(Integer userId) { - List customs = customProvider.getAllByUserIdAndIsCompleted(userId); - return ReadCustomSummaryListRes.from(customs); - } + @Override + @Transactional(readOnly = true) + public ReadCustomSummaryListRes readCustomSummaryCompleteListByUserId(Integer userId) { + List customs = customProvider.getAllByUserIdAndIsCompleted(userId); + return ReadCustomSummaryListRes.from(customs); + } - @Override - @Transactional(readOnly = true) - public ReadCustomSummaryListRes readCustomSummaryInCompleteListByUserId(Integer userId) { - List customs = customProvider.getAllByUserIdAndIsCompletedFalse(userId); - return ReadCustomSummaryListRes.from(customs); - } + @Override + @Transactional(readOnly = true) + public ReadCustomSummaryListRes readCustomSummaryInCompleteListByUserId(Integer userId) { + List customs = customProvider.getAllByUserIdAndIsCompletedFalse(userId); + return ReadCustomSummaryListRes.from(customs); + } - @Override - @Transactional - public ReadCustomRes updateCustom(UpdateCustomReq updateCustomReq) { - Custom custom = customProvider.getCustomById( - updateCustomReq.getCustomId(), - updateCustomReq.getUserId()); - Custom updateCustom = updateCustomReq.newCustom(); + @Override + @Transactional + public ReadCustomRes updateCustom(UpdateCustomReq updateCustomReq) { + Custom custom = customProvider.getCustomById( + updateCustomReq.getCustomId(), + updateCustomReq.getUserId()); + Custom updateCustom = updateCustomReq.newCustom(); - // 손그림 등록 - if (!Objects.isNull(updateCustomReq.getHandDrawingImage())) { - customService.setHandDrawingImage( - updateCustom, - updateCustomReq.getHandDrawingImage()); - } + // 손그림 등록 + if (!Objects.isNull(updateCustomReq.getHandDrawingImage())) { + customService.setHandDrawingImage( + updateCustom, + updateCustomReq.getHandDrawingImage()); + } - // 이미지 리스트의 첫번째가 메인 이미지임 - if (!Objects.isNull(updateCustomReq.getImages())) { - if (updateCustomReq.getImages().size() > 0) { - customService.setMainImageUrl( - updateCustom, - updateCustomReq.getImages().get(0)); - updateCustomReq.getImages().remove(0); - } - } - customService.updateCustom(custom, updateCustom); + // 이미지 리스트의 첫번째가 메인 이미지임 + if (!Objects.isNull(updateCustomReq.getImages())) { + if (updateCustomReq.getImages().size() > 0) { + customService.setMainImageUrl( + updateCustom, + updateCustomReq.getImages().get(0)); + updateCustomReq.getImages().remove(0); + } + } + customService.updateCustom(custom, updateCustom); - // 이미지들 등록 - if (!Objects.isNull(updateCustomReq.getImages())) { - List customImages = - s3Service.uploadImageList( - updateCustomReq.getImages(), - directoryPath) - .stream() - .map(image -> CustomImage.of(image, custom)) - .collect(Collectors.toList()); - customImageService.saveAll(customImages); - } + // 이미지들 등록 + if (!Objects.isNull(updateCustomReq.getImages())) { + List customImages = + s3Service.uploadImageList( + updateCustomReq.getImages(), + directoryPath) + .stream() + .map(image -> CustomImage.of(image, custom)) + .collect(Collectors.toList()); + customImageService.saveAll(customImages); + } - // 테마 등록 - if (!Objects.isNull(updateCustomReq.getThemes())) { - customThemeService.saveAllByCustomAndThemeIdList( - custom, - updateCustomReq.getThemes()); - } - // 스타일 등록 - if (!Objects.isNull(updateCustomReq.getStyles())) { - customStyleService.saveByCustomAndStyleIdList( - custom, - updateCustomReq.getStyles()); - } - if (custom.getIsCompleted()) { - discordMessageService.sendCustomApplyMessage(custom); - userService.updateUserPoint(custom.getUser(), -custom.getPrice()); - } - return ReadCustomRes.from(custom); - } + // 테마 등록 + if (!Objects.isNull(updateCustomReq.getThemes())) { + customThemeService.saveAllByCustomAndThemeIdList( + custom, + updateCustomReq.getThemes()); + } + // 스타일 등록 + if (!Objects.isNull(updateCustomReq.getStyles())) { + customStyleService.saveByCustomAndStyleIdList( + custom, + updateCustomReq.getStyles()); + } + if (custom.getIsCompleted()) { + discordMessageService.sendCustomApplyMessage(custom); + } + return ReadCustomRes.from(custom); + } - @Override - @Transactional - public ReadCustomRes updateCustomProcess(UpdateCustomReq updateCustomReq) { - Custom custom = - customProvider.getCustomById( - updateCustomReq.getCustomId(), - updateCustomReq.getUserId()); - customService.updateCustomProcess(custom, updateCustomReq.getCustomProcess()); - return ReadCustomRes.from(custom); - } + @Override + @Transactional + public ReadCustomRes updateCustomProcess(UpdateCustomReq updateCustomReq) { + Custom custom = + customProvider.getCustomById( + updateCustomReq.getCustomId(), + updateCustomReq.getUserId()); + customService.updateCustomProcess(custom, updateCustomReq.getCustomProcess()); + return ReadCustomRes.from(custom); + } } diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java b/server/src/main/java/org/tattour/server/domain/custom/model/Custom.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java rename to server/src/main/java/org/tattour/server/domain/custom/model/Custom.java index 45474278..6edc106d 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/Custom.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/Custom.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import java.util.ArrayList; import java.util.List; @@ -22,8 +22,8 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.user.model.User; import org.tattour.server.global.util.AuditingTimeEntity; @Getter @@ -85,9 +85,6 @@ public class Custom extends AuditingTimeEntity { private Integer price; - /** - * Mapped By - */ @OneToMany(mappedBy = "custom") private List customThemes = new ArrayList<>(); @@ -162,7 +159,7 @@ public void setCustomProcess(CustomProcess process) { } public Integer calPrice() { - Integer price = size.getPrice() * count; + int price = size.getPrice() * count; if (isPublic) { price -= size.getDiscountPrice(); } diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomImage.java b/server/src/main/java/org/tattour/server/domain/custom/model/CustomImage.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/custom/domain/CustomImage.java rename to server/src/main/java/org/tattour/server/domain/custom/model/CustomImage.java index ba21288f..fcb05773 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomImage.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/CustomImage.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomProcess.java b/server/src/main/java/org/tattour/server/domain/custom/model/CustomProcess.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/custom/domain/CustomProcess.java rename to server/src/main/java/org/tattour/server/domain/custom/model/CustomProcess.java index 734e29d4..952b8121 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomProcess.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/CustomProcess.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import lombok.AccessLevel; import lombok.Getter; diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomSize.java b/server/src/main/java/org/tattour/server/domain/custom/model/CustomSize.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/custom/domain/CustomSize.java rename to server/src/main/java/org/tattour/server/domain/custom/model/CustomSize.java index d9fee3dc..23f98f3f 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomSize.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/CustomSize.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import lombok.AccessLevel; import lombok.Getter; diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomStyle.java b/server/src/main/java/org/tattour/server/domain/custom/model/CustomStyle.java similarity index 91% rename from server/src/main/java/org/tattour/server/domain/custom/domain/CustomStyle.java rename to server/src/main/java/org/tattour/server/domain/custom/model/CustomStyle.java index 6cfdfba6..feaf383b 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomStyle.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/CustomStyle.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,7 +13,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.tattour.server.domain.style.domain.Style; +import org.tattour.server.domain.style.model.Style; @Getter @Table(name = "custom_style") diff --git a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomTheme.java b/server/src/main/java/org/tattour/server/domain/custom/model/CustomTheme.java similarity index 91% rename from server/src/main/java/org/tattour/server/domain/custom/domain/CustomTheme.java rename to server/src/main/java/org/tattour/server/domain/custom/model/CustomTheme.java index 76a5092c..48db4ac9 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/domain/CustomTheme.java +++ b/server/src/main/java/org/tattour/server/domain/custom/model/CustomTheme.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.custom.domain; +package org.tattour.server.domain.custom.model; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -14,7 +14,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.theme.domain.Theme; +import org.tattour.server.domain.theme.model.Theme; @Getter @Table(name = "custom_theme") diff --git a/server/src/main/java/org/tattour/server/domain/custom/provider/CustomProvider.java b/server/src/main/java/org/tattour/server/domain/custom/provider/CustomProvider.java index e3c42c3f..59201969 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/provider/CustomProvider.java +++ b/server/src/main/java/org/tattour/server/domain/custom/provider/CustomProvider.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.provider; import java.util.List; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; public interface CustomProvider { diff --git a/server/src/main/java/org/tattour/server/domain/custom/provider/impl/CustomProviderImpl.java b/server/src/main/java/org/tattour/server/domain/custom/provider/impl/CustomProviderImpl.java index db852b26..76009b25 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/provider/impl/CustomProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/provider/impl/CustomProviderImpl.java @@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; import org.tattour.server.domain.custom.exception.NotFoundCustomException; import org.tattour.server.domain.custom.provider.CustomProvider; import org.tattour.server.domain.custom.repository.CustomRepository; diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomImageRepository.java b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomImageRepository.java index e9440c80..0541ec74 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomImageRepository.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomImageRepository.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.repository; import java.util.List; -import org.tattour.server.domain.custom.domain.CustomImage; +import org.tattour.server.domain.custom.model.CustomImage; public interface CustomImageRepository { diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomRepository.java b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomRepository.java index 76885e68..941c2cb5 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomRepository.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomRepository.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Optional; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; import org.tattour.server.domain.custom.repository.custom.CustomRepositoryCustom; public interface CustomRepository extends diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomStyleRepository.java b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomStyleRepository.java index 0b47d432..2632eb1d 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomStyleRepository.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomStyleRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Optional; -import org.tattour.server.domain.custom.domain.CustomStyle; +import org.tattour.server.domain.custom.model.CustomStyle; public interface CustomStyleRepository { diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomThemeRepository.java b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomThemeRepository.java index 682fdab0..7f3dac20 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/CustomThemeRepository.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/CustomThemeRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Optional; -import org.tattour.server.domain.custom.domain.CustomTheme; +import org.tattour.server.domain.custom.model.CustomTheme; public interface CustomThemeRepository { diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/custom/CustomRepositoryCustom.java b/server/src/main/java/org/tattour/server/domain/custom/repository/custom/CustomRepositoryCustom.java index 4c587772..94a8f343 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/custom/CustomRepositoryCustom.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/custom/CustomRepositoryCustom.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.repository.custom; import java.util.List; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; public interface CustomRepositoryCustom { diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomImageRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomImageRepositoryImpl.java index c68df074..0e3fd38d 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomImageRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomImageRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.custom.domain.CustomImage; +import org.tattour.server.domain.custom.model.CustomImage; import org.tattour.server.domain.custom.repository.CustomImageRepository; public interface CustomImageRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomRepositoryImpl.java index 6a4d697d..17d6ab88 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomRepositoryImpl.java @@ -1,33 +1,33 @@ package org.tattour.server.domain.custom.repository.impl; -import static org.tattour.server.domain.custom.domain.QCustom.*; +import static org.tattour.server.domain.custom.model.QCustom.*; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import lombok.RequiredArgsConstructor; -import org.tattour.server.domain.custom.domain.Custom; +import org.tattour.server.domain.custom.model.Custom; import org.tattour.server.domain.custom.repository.custom.CustomRepositoryCustom; @RequiredArgsConstructor public class CustomRepositoryImpl implements CustomRepositoryCustom { - private final JPAQueryFactory queryFactory; + private final JPAQueryFactory queryFactory; - @Override - public List findAllByUserIdAndIsCompleted(Integer userId) { - return queryFactory - .select(custom) - .from(custom) - .where(custom.user.id.eq(userId), custom.isCompleted.eq(true)) - .fetch(); - } + @Override + public List findAllByUserIdAndIsCompleted(Integer userId) { + return queryFactory + .select(custom) + .from(custom) + .where(custom.user.id.eq(userId), custom.isCompleted.eq(true)) + .fetch(); + } - @Override - public List findAllByUserIdAndIsCompletedFalse(Integer userId) { - return queryFactory - .select(custom) - .from(custom) - .where(custom.user.id.eq(userId), custom.isCompleted.eq(false)) - .fetch(); - } + @Override + public List findAllByUserIdAndIsCompletedFalse(Integer userId) { + return queryFactory + .select(custom) + .from(custom) + .where(custom.user.id.eq(userId), custom.isCompleted.eq(false)) + .fetch(); + } } diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomStyleRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomStyleRepositoryImpl.java index 645f192d..d97a215a 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomStyleRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomStyleRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.custom.domain.CustomStyle; +import org.tattour.server.domain.custom.model.CustomStyle; import org.tattour.server.domain.custom.repository.CustomStyleRepository; public interface CustomStyleRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomThemeRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomThemeRepositoryImpl.java index 7be4175e..2f1e64f2 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomThemeRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/repository/impl/CustomThemeRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.custom.domain.CustomTheme; +import org.tattour.server.domain.custom.model.CustomTheme; import org.tattour.server.domain.custom.repository.CustomThemeRepository; public interface CustomThemeRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/CustomImageService.java b/server/src/main/java/org/tattour/server/domain/custom/service/CustomImageService.java index 7ea9f1fc..ea5e4543 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/CustomImageService.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/CustomImageService.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.custom.service; import java.util.List; -import org.tattour.server.domain.custom.domain.CustomImage; +import org.tattour.server.domain.custom.model.CustomImage; public interface CustomImageService { diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/CustomService.java b/server/src/main/java/org/tattour/server/domain/custom/service/CustomService.java index ca7f3b04..e40a2d38 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/CustomService.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/CustomService.java @@ -1,21 +1,21 @@ package org.tattour.server.domain.custom.service; import org.springframework.web.multipart.MultipartFile; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomProcess; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomProcess; +import org.tattour.server.domain.user.model.User; public interface CustomService { - Custom save(Custom custom); + Custom save(Custom custom); - Custom createInitCustom(User user, Boolean haveDesign); + Custom createInitCustom(User user, Boolean haveDesign); - Custom updateCustom(Custom custom, Custom updateCustomInfo); + Custom updateCustom(Custom custom, Custom updateCustomInfo); - Custom updateCustomProcess(Custom updateCustom, CustomProcess customProcess); + Custom updateCustomProcess(Custom updateCustom, CustomProcess customProcess); - void setHandDrawingImage(Custom updateCustom, MultipartFile handDrawingImage); + void setHandDrawingImage(Custom updateCustom, MultipartFile handDrawingImage); - void setMainImageUrl(Custom updateCustom, MultipartFile mainImage); + void setMainImageUrl(Custom updateCustom, MultipartFile mainImage); } diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/CustomStyleService.java b/server/src/main/java/org/tattour/server/domain/custom/service/CustomStyleService.java index 3e11e4a6..385a66c5 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/CustomStyleService.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/CustomStyleService.java @@ -1,8 +1,8 @@ package org.tattour.server.domain.custom.service; import java.util.List; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomStyle; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomStyle; public interface CustomStyleService { diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/CustomThemeService.java b/server/src/main/java/org/tattour/server/domain/custom/service/CustomThemeService.java index ebbff90c..9185de16 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/CustomThemeService.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/CustomThemeService.java @@ -1,8 +1,8 @@ package org.tattour.server.domain.custom.service; import java.util.List; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomTheme; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomTheme; public interface CustomThemeService { diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomImageServiceImpl.java b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomImageServiceImpl.java index c7579936..32865502 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomImageServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomImageServiceImpl.java @@ -3,7 +3,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.tattour.server.domain.custom.domain.CustomImage; +import org.tattour.server.domain.custom.model.CustomImage; import org.tattour.server.domain.custom.repository.CustomImageRepository; import org.tattour.server.domain.custom.service.CustomImageService; diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomServiceImpl.java b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomServiceImpl.java index 2334ed6e..5a7894d7 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomServiceImpl.java @@ -6,13 +6,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomProcess; import org.tattour.server.domain.custom.exception.InvalidCustomCompletedException; import org.tattour.server.domain.custom.exception.InvalidCustomPriceException; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomProcess; import org.tattour.server.domain.custom.repository.CustomRepository; import org.tattour.server.domain.custom.service.CustomService; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.user.model.User; import org.tattour.server.infra.s3.S3Service; @Slf4j @@ -20,100 +20,100 @@ @RequiredArgsConstructor public class CustomServiceImpl implements CustomService { - private final CustomRepository customRepository; - private final S3Service s3Service; + private final CustomRepository customRepository; + private final S3Service s3Service; - @Value("${image.default.custom}") - private String defaultImageUrl; - private static final String directoryPath = "custom"; + @Value("${image.default.custom}") + private String defaultImageUrl; + private static final String directoryPath = "custom"; - @Override - public Custom save(Custom custom) { - return customRepository.save(custom); - } + @Override + public Custom save(Custom custom) { + return customRepository.save(custom); + } - @Override - public Custom createInitCustom(User user, Boolean haveDesign) { - return Custom.of( - user, - haveDesign, - "임시 저장", - defaultImageUrl, - false, - 0); - } + @Override + public Custom createInitCustom(User user, Boolean haveDesign) { + return Custom.of( + user, + haveDesign, + "임시 저장", + defaultImageUrl, + false, + 0); + } - @Override - public Custom updateCustom(Custom custom, Custom updateCustom) { - if(!Objects.isNull(updateCustom.getMainImageUrl())) { - custom.setMainImageUrl(updateCustom.getMainImageUrl()); - } - if(!Objects.isNull(updateCustom.getHandDrawingImageUrl())) { - custom.setHandDrawingImageUrl(updateCustom.getHandDrawingImageUrl()); - } - if (!Objects.isNull(updateCustom.getSize())) { - custom.setSize(updateCustom.getSize()); - } - if (!Objects.isNull(updateCustom.getName())) { - custom.setName(updateCustom.getName()); - } - if (!Objects.isNull(updateCustom.getDescription())) { - custom.setDescription(updateCustom.getDescription()); - } - if (!Objects.isNull(updateCustom.getDemand())) { - custom.setDemand(updateCustom.getDemand()); - } - if (!Objects.isNull(updateCustom.getCount())) { - custom.setCount(updateCustom.getCount()); - } - if (!Objects.isNull(updateCustom.getIsColored())) { - custom.setColored(updateCustom.getIsColored()); - } - if (!Objects.isNull(updateCustom.getIsPublic())) { - custom.setPublic(updateCustom.getIsPublic()); - } - if (!Objects.isNull(updateCustom.getViewCount())) { - custom.setViewCount(updateCustom.getViewCount()); - } - if (!Objects.isNull(updateCustom.getIsCompleted())) { - if (updateCustom.getIsCompleted()) { - if (!custom.calPrice().equals(updateCustom.getPrice())) { - throw new InvalidCustomPriceException(); - } - custom.setPrice(updateCustom.getPrice()); - custom.setCompleted(updateCustom.getIsCompleted()); - custom.setCustomProcess(CustomProcess.RECEIVING); - } - } - return customRepository.save(custom); - } + @Override + public Custom updateCustom(Custom custom, Custom updateCustom) { + if (!Objects.isNull(updateCustom.getMainImageUrl())) { + custom.setMainImageUrl(updateCustom.getMainImageUrl()); + } + if (!Objects.isNull(updateCustom.getHandDrawingImageUrl())) { + custom.setHandDrawingImageUrl(updateCustom.getHandDrawingImageUrl()); + } + if (!Objects.isNull(updateCustom.getSize())) { + custom.setSize(updateCustom.getSize()); + } + if (!Objects.isNull(updateCustom.getName())) { + custom.setName(updateCustom.getName()); + } + if (!Objects.isNull(updateCustom.getDescription())) { + custom.setDescription(updateCustom.getDescription()); + } + if (!Objects.isNull(updateCustom.getDemand())) { + custom.setDemand(updateCustom.getDemand()); + } + if (!Objects.isNull(updateCustom.getCount())) { + custom.setCount(updateCustom.getCount()); + } + if (!Objects.isNull(updateCustom.getIsColored())) { + custom.setColored(updateCustom.getIsColored()); + } + if (!Objects.isNull(updateCustom.getIsPublic())) { + custom.setPublic(updateCustom.getIsPublic()); + } + if (!Objects.isNull(updateCustom.getViewCount())) { + custom.setViewCount(updateCustom.getViewCount()); + } + if (!Objects.isNull(updateCustom.getIsCompleted())) { + if (updateCustom.getIsCompleted()) { + if (!custom.calPrice().equals(updateCustom.getPrice())) { + throw new InvalidCustomPriceException(); + } + custom.setPrice(updateCustom.getPrice()); + custom.setCompleted(updateCustom.getIsCompleted()); + custom.setCustomProcess(CustomProcess.RECEIVING); + } + } + return customRepository.save(custom); + } - @Override - public Custom updateCustomProcess(Custom custom, CustomProcess customProcess) { - if(Objects.isNull(custom.getIsCompleted())) { - throw new InvalidCustomCompletedException(); - } - if (!custom.getIsCompleted()) { - throw new InvalidCustomCompletedException(); - } - custom.setCustomProcess(customProcess); - return custom; - } + @Override + public Custom updateCustomProcess(Custom custom, CustomProcess customProcess) { + if (Objects.isNull(custom.getIsCompleted())) { + throw new InvalidCustomCompletedException(); + } + if (!custom.getIsCompleted()) { + throw new InvalidCustomCompletedException(); + } + custom.setCustomProcess(customProcess); + return custom; + } - @Override - public void setHandDrawingImage(Custom updateCustom, MultipartFile handDrawingImage) { - updateCustom.setHandDrawingImageUrl( - s3Service.uploadImage( - handDrawingImage, - directoryPath)); - } + @Override + public void setHandDrawingImage(Custom updateCustom, MultipartFile handDrawingImage) { + updateCustom.setHandDrawingImageUrl( + s3Service.uploadImage( + handDrawingImage, + directoryPath)); + } - @Override - public void setMainImageUrl(Custom updateCustom, MultipartFile mainImage) { - updateCustom.setMainImageUrl( - s3Service.uploadImage( - mainImage, - directoryPath)); - } + @Override + public void setMainImageUrl(Custom updateCustom, MultipartFile mainImage) { + updateCustom.setMainImageUrl( + s3Service.uploadImage( + mainImage, + directoryPath)); + } } diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomStyleServiceImpl.java b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomStyleServiceImpl.java index af843b56..28edd6f3 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomStyleServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomStyleServiceImpl.java @@ -5,8 +5,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomStyle; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomStyle; import org.tattour.server.domain.custom.repository.CustomStyleRepository; import org.tattour.server.domain.custom.service.CustomStyleService; import org.tattour.server.domain.style.provider.StyleProvider; diff --git a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomThemeServiceImpl.java b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomThemeServiceImpl.java index fcaac305..1ed57935 100644 --- a/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomThemeServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/custom/service/impl/CustomThemeServiceImpl.java @@ -5,8 +5,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.tattour.server.domain.custom.domain.Custom; -import org.tattour.server.domain.custom.domain.CustomTheme; +import org.tattour.server.domain.custom.model.Custom; +import org.tattour.server.domain.custom.model.CustomTheme; import org.tattour.server.domain.custom.repository.CustomThemeRepository; import org.tattour.server.domain.custom.service.CustomThemeService; import org.tattour.server.domain.theme.provider.ThemeProvider; diff --git a/server/src/main/java/org/tattour/server/domain/discount/facade/dto/request/CreateDiscountReq.java b/server/src/main/java/org/tattour/server/domain/discount/facade/dto/request/CreateDiscountReq.java index 466e24b5..e5fd7b23 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/facade/dto/request/CreateDiscountReq.java +++ b/server/src/main/java/org/tattour/server/domain/discount/facade/dto/request/CreateDiscountReq.java @@ -4,7 +4,6 @@ import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.discount.domain.Discount; @Getter @Builder(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/discount/facade/impl/DiscountFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/discount/facade/impl/DiscountFacadeImpl.java index 3b24b5ff..701ac782 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/facade/impl/DiscountFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/discount/facade/impl/DiscountFacadeImpl.java @@ -3,12 +3,12 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.discount.domain.Discount; +import org.tattour.server.domain.discount.model.Discount; import org.tattour.server.domain.discount.provider.DiscountProvider; import org.tattour.server.domain.discount.repository.DiscountRepository; import org.tattour.server.domain.discount.facade.DiscountFacade; import org.tattour.server.domain.discount.facade.dto.request.CreateDiscountReq; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.facade.dto.response.ReadStickerRes; import org.tattour.server.domain.sticker.provider.StickerProvider; diff --git a/server/src/main/java/org/tattour/server/domain/discount/domain/Discount.java b/server/src/main/java/org/tattour/server/domain/discount/model/Discount.java similarity index 96% rename from server/src/main/java/org/tattour/server/domain/discount/domain/Discount.java rename to server/src/main/java/org/tattour/server/domain/discount/model/Discount.java index 6dfb8b17..f897318f 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/domain/Discount.java +++ b/server/src/main/java/org/tattour/server/domain/discount/model/Discount.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.discount.domain; +package org.tattour.server.domain.discount.model; import java.time.LocalDateTime; import javax.persistence.Column; diff --git a/server/src/main/java/org/tattour/server/domain/discount/provider/DiscountProvider.java b/server/src/main/java/org/tattour/server/domain/discount/provider/DiscountProvider.java index e0352594..8d808d86 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/provider/DiscountProvider.java +++ b/server/src/main/java/org/tattour/server/domain/discount/provider/DiscountProvider.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.discount.provider; -import org.tattour.server.domain.discount.domain.Discount; +import org.tattour.server.domain.discount.model.Discount; public interface DiscountProvider { diff --git a/server/src/main/java/org/tattour/server/domain/discount/provider/impl/DiscountProviderImpl.java b/server/src/main/java/org/tattour/server/domain/discount/provider/impl/DiscountProviderImpl.java index 1fd5be82..0ade7ae0 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/provider/impl/DiscountProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/discount/provider/impl/DiscountProviderImpl.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import org.tattour.server.domain.discount.domain.Discount; +import org.tattour.server.domain.discount.model.Discount; import org.tattour.server.domain.discount.exception.NotFoundDiscountException; import org.tattour.server.domain.discount.provider.DiscountProvider; import org.tattour.server.domain.discount.repository.DiscountRepository; diff --git a/server/src/main/java/org/tattour/server/domain/discount/repository/DiscountRepository.java b/server/src/main/java/org/tattour/server/domain/discount/repository/DiscountRepository.java index 4cbd95c5..54616691 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/repository/DiscountRepository.java +++ b/server/src/main/java/org/tattour/server/domain/discount/repository/DiscountRepository.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.discount.repository; import java.util.Optional; -import org.tattour.server.domain.discount.domain.Discount; +import org.tattour.server.domain.discount.model.Discount; public interface DiscountRepository { diff --git a/server/src/main/java/org/tattour/server/domain/discount/repository/impl/DiscountRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/discount/repository/impl/DiscountRepositoryImpl.java index 133d1101..06e5a4ad 100644 --- a/server/src/main/java/org/tattour/server/domain/discount/repository/impl/DiscountRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/discount/repository/impl/DiscountRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.discount.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.discount.domain.Discount; +import org.tattour.server.domain.discount.model.Discount; import org.tattour.server.domain.discount.repository.DiscountRepository; public interface DiscountRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineRes.java b/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineRes.java index 836e0f75..5e91fe51 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineRes.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineRes.java @@ -3,7 +3,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; @Getter @AllArgsConstructor(access = AccessLevel.PACKAGE) diff --git a/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineUrlRes.java b/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineUrlRes.java index f5c726a2..e65c8da7 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineUrlRes.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/facade/dto/response/ReadMagazineUrlRes.java @@ -2,7 +2,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; @Getter @AllArgsConstructor diff --git a/server/src/main/java/org/tattour/server/domain/magazine/domain/Magazine.java b/server/src/main/java/org/tattour/server/domain/magazine/model/Magazine.java similarity index 94% rename from server/src/main/java/org/tattour/server/domain/magazine/domain/Magazine.java rename to server/src/main/java/org/tattour/server/domain/magazine/model/Magazine.java index 4aed715f..a2ce32ce 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/domain/Magazine.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/model/Magazine.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.magazine.domain; +package org.tattour.server.domain.magazine.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/server/src/main/java/org/tattour/server/domain/magazine/provider/MagazineProvider.java b/server/src/main/java/org/tattour/server/domain/magazine/provider/MagazineProvider.java index 79d8e0d3..d043da87 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/provider/MagazineProvider.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/provider/MagazineProvider.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.magazine.provider; import java.util.List; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; public interface MagazineProvider { diff --git a/server/src/main/java/org/tattour/server/domain/magazine/provider/impl/MagazineProviderImpl.java b/server/src/main/java/org/tattour/server/domain/magazine/provider/impl/MagazineProviderImpl.java index 14cd22c1..3367b2f5 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/provider/impl/MagazineProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/provider/impl/MagazineProviderImpl.java @@ -3,7 +3,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; import org.tattour.server.domain.magazine.exception.NotFoundMagazineException; import org.tattour.server.domain.magazine.provider.MagazineProvider; import org.tattour.server.domain.magazine.repository.MagazineRepository; diff --git a/server/src/main/java/org/tattour/server/domain/magazine/repository/MagazineRepository.java b/server/src/main/java/org/tattour/server/domain/magazine/repository/MagazineRepository.java index 222002e0..3c7b228d 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/repository/MagazineRepository.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/repository/MagazineRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Optional; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; public interface MagazineRepository { diff --git a/server/src/main/java/org/tattour/server/domain/magazine/repository/impl/MagazineRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/magazine/repository/impl/MagazineRepositoryImpl.java index 7f01d6a1..61477459 100644 --- a/server/src/main/java/org/tattour/server/domain/magazine/repository/impl/MagazineRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/magazine/repository/impl/MagazineRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.magazine.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.magazine.domain.Magazine; +import org.tattour.server.domain.magazine.model.Magazine; import org.tattour.server.domain.magazine.repository.MagazineRepository; public interface MagazineRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/OrderController.java b/server/src/main/java/org/tattour/server/domain/order/controller/OrderController.java index a89a29ed..fc48fab2 100644 --- a/server/src/main/java/org/tattour/server/domain/order/controller/OrderController.java +++ b/server/src/main/java/org/tattour/server/domain/order/controller/OrderController.java @@ -9,21 +9,21 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import javax.validation.Valid; -import javax.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import org.tattour.server.domain.order.controller.dto.request.PostOrderReq; +import org.tattour.server.domain.order.controller.dto.request.OrderReq; import org.tattour.server.domain.order.controller.dto.response.ReadOrderSheetRes; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.facade.impl.OrderFacadeImpl; -import org.tattour.server.domain.order.facade.dto.request.ReadOrderSheetReq; +import org.tattour.server.domain.order.facade.dto.request.CreateOrderReq; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; +import org.tattour.server.domain.order.facade.impl.OrderFacadeImpl; +import org.tattour.server.domain.order.model.PurchaseRequest; import org.tattour.server.global.config.annotations.UserId; import org.tattour.server.global.dto.BaseResponse; import org.tattour.server.global.dto.FailResponse; @@ -35,127 +35,131 @@ @RequiredArgsConstructor @SecurityRequirement(name = "JWT Auth") @Tag(name = "Order", description = "Order API Document") +@Validated public class OrderController { - private final OrderFacadeImpl orderFacade; + private final OrderFacadeImpl orderFacade; - @Operation(summary = "결제 페이지 불러오기", description = "제품 상세 페이지에서 받은 정보를 바탕으로 결제 시트 정보 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadOrderSheetRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 스티커입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/ordersheet") - public ResponseEntity getOrderSheet( - @Parameter(hidden = true) @UserId Integer userId, - @Parameter(description = "타투 스티커 id") @RequestParam @NotNull(message = "stickerId is null") Integer stickerId, - @Parameter(description = "상품 개수", example = "3") @RequestParam @NotNull(message = "count is null") Integer count, - @Parameter(description = "배송비", example = "3000") @RequestParam @NotNull(message = "shippingFee is null") Integer shippingFee - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, - orderFacade.readOrderSheet( - ReadOrderSheetReq.of( - userId, - stickerId, - count, - shippingFee))); - } + // todo: 장바구니 목록이 존재하지 않을 경우 예외처리하기 + @Operation(summary = "결제 페이지 불러오기", + description = "결제 페이지 정보 불러오기" + + "\n- stickerId, count가 존재하는 경우: **단일 상품 구매**" + + "\n- stickerId, count가 존재하지 않는 경우: **장바구니 상품 구매**") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "조회에 성공했습니다.", + content = @Content(schema = @Schema(implementation = ReadOrderSheetRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 스티커입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping("/ordersheet") + public ResponseEntity getOrderSheet( + @Parameter(hidden = true) @UserId Integer userId, + @Parameter(description = "타투 스티커 id") @RequestParam(required = false) Integer stickerId, + @Parameter(description = "상품 개수") @RequestParam(required = false) Integer count + ) { + return BaseResponse.success( + SuccessType.GET_SUCCESS, + orderFacade.readOrderSheet(userId, PurchaseRequest.of(stickerId, count))); + } - @Operation(summary = "결제하기", description = "결제 시트 페이지에서 결제하기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "주문에 성공했습니다.", - content = @Content(schema = @Schema(implementation = SuccessResponse.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "403", - description = "포인트가 부족하여 결제할 수 없습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 스티커입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @PostMapping - public ResponseEntity order( - @Parameter(hidden = true) @UserId Integer userId, - @RequestBody @Valid PostOrderReq req - ) { - orderFacade.createOrder(CreateOrderRequest.of( - userId, - req.getStickerId(), - req.getProductCount(), - req.getShippingFee(), - req.getTotalAmount(), - req.getRecipientName(), - req.getContact(), - req.getMailingAddress(), - req.getBaseAddress(), - req.getDetailAddress())); + @Operation(summary = "결제하기", + description = "결제 페이지에서 결제하기" + + "\n- stickerId, count가 존재하는 경우: **단일 상품 구매**" + + "\n- stickerId, count가 존재하지 않는 경우: **장바구니 상품 구매**") + @ApiResponses(value = { + @ApiResponse( + responseCode = "201", + description = "주문에 성공했습니다.", + content = @Content(schema = @Schema(implementation = SuccessResponse.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 스티커입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @PostMapping + public ResponseEntity order( + @Parameter(hidden = true) @UserId Integer userId, + @RequestBody @Valid OrderReq orderReq, + @Parameter(description = "타투 스티커 id") @RequestParam(required = false) Integer stickerId, + @Parameter(description = "상품 개수") @RequestParam(required = false) Integer count + ) { + orderFacade.order( + PurchaseRequest.of(stickerId, count), + CreateOrderReq.builder() + .userId(userId) + .productAmount(orderReq.getProductAmount()) + .shippingFee(orderReq.getShippingFee()) + .totalAmount(orderReq.getTotalAmount()) + .recipientName(orderReq.getRecipientName()) + .contact(orderReq.getContact()) + .mailingAddress(orderReq.getMailingAddress()) + .baseAddress(orderReq.getBaseAddress()) + .detailAddress(orderReq.getDetailAddress()) + .build()); - return BaseResponse.success(SuccessType.CREATE_ORDER_SUCCESS); - } + return BaseResponse.success(SuccessType.CREATE_ORDER_SUCCESS); + } - // TODO : pageable로 리팩토링하기 - @Operation(summary = "유저 결제 내역 불러오기", description = "유저 id로 결제 내역 불러오기") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "조회에 성공했습니다.", - content = @Content(schema = @Schema(implementation = ReadUserOrderHistoryListRes.class))), - @ApiResponse( - responseCode = "400", - description = "잘못된 요청입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 유저입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 스티커입니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))), - @ApiResponse( - responseCode = "500", - description = "알 수 없는 서버 에러가 발생했습니다.", - content = @Content(schema = @Schema(implementation = FailResponse.class))) - }) - @GetMapping("/history") - public ResponseEntity getUserOrderList( - @Parameter(hidden = true) @UserId Integer userId - ) { - return BaseResponse.success(SuccessType.GET_SUCCESS, - orderFacade.readOrderHistoryByUserId(userId)); - } + // TODO: pageable로 리팩토링하기 + // TODO: 결제 내역 response 내용 수정하기 + @Operation(summary = "유저 결제 내역 불러오기", description = "유저 id로 결제 내역 불러오기") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "조회에 성공했습니다.", + content = @Content(schema = @Schema(implementation = ReadUserOrderHistoryListRes.class))), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 유저입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "404", + description = "존재하지 않는 스티커입니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))), + @ApiResponse( + responseCode = "500", + description = "알 수 없는 서버 에러가 발생했습니다.", + content = @Content(schema = @Schema(implementation = FailResponse.class))) + }) + @GetMapping("/history") + public ResponseEntity getUserOrderList( + @Parameter(hidden = true) @UserId Integer userId + ) { + return BaseResponse.success(SuccessType.GET_SUCCESS, + orderFacade.readOrderHistoryByUserId(userId)); + } } diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PostOrderReq.java b/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/OrderReq.java similarity index 81% rename from server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PostOrderReq.java rename to server/src/main/java/org/tattour/server/domain/order/controller/dto/request/OrderReq.java index 02c7bee6..8da4a2ad 100644 --- a/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PostOrderReq.java +++ b/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/OrderReq.java @@ -10,23 +10,18 @@ @Schema(description = "결제하기 Request") @Getter -public class PostOrderReq { - - @Schema(description = "타투 스티커 Id") - @NotNull(message = "stickerId is null") - private Integer stickerId; - - @Schema(description = "상품 개수", example = "3") - @NotNull(message = "productCount is null") - @Min(value = 1) - private Integer productCount; +public class OrderReq { + @Schema(description = "상품 금액", example = "9000") + @NotNull(message = "productAmount is null") + @Min(value = 0) + private Integer productAmount; @Schema(description = "배송비", example = "3000") @NotNull(message = "shippingFee is null") @Min(value = 0) private Integer shippingFee; - @Schema(description = "총 주문금액", example = "12000") + @Schema(description = "총 주문 금액", example = "12000") @NotNull(message = "totalAmount is null") @Min(value = 0) private Integer totalAmount; diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PatchOrderStatusReq.java b/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PatchOrderStatusReq.java index 1e231095..5bd5e82d 100644 --- a/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PatchOrderStatusReq.java +++ b/server/src/main/java/org/tattour/server/domain/order/controller/dto/request/PatchOrderStatusReq.java @@ -3,7 +3,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import javax.validation.constraints.NotNull; import lombok.Getter; -import org.tattour.server.domain.order.domain.OrderStatus; +import org.tattour.server.domain.order.model.OrderStatus; @Schema(description = "주문상태 갱신 Request (PREPARATION / CANCEL / ACCEPT / DELIVERING / DELIVERED)") @Getter diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/OrderSheetStickerRes.java b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/OrderSheetStickerRes.java new file mode 100644 index 00000000..09b5bac0 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/OrderSheetStickerRes.java @@ -0,0 +1,43 @@ +package org.tattour.server.domain.order.controller.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +// Todo: 리펙토링 필요 +@Schema(description = "타투 스티커 정보") +@Getter +@Setter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class OrderSheetStickerRes { + + @Schema(description = "메인 배너 이미지", example = "https://tattoo170829.wisacdn.com/data/file/tattoo_posting/833046566_5d1d5fc1db100.jpg") + private String mainImageUrl; + + @Schema(description = "타투 스티커 이름", example = "포효하는 호랑이") + private String name; + + @Schema(description = "가격", example = "3500") + private Integer price; + + @Schema(description = "할인된 가격", example = "3150") + private Integer discountPrice; + + @Schema(description = "상품 개수", example = "3") + private Integer count; + + public static OrderSheetStickerRes of( + String mainImageUrl, + String name, + int price, + Integer discountPrice, + int count) { + return new OrderSheetStickerRes(mainImageUrl, name, price, discountPrice, count); + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java index 2b0cf00f..f32dec4c 100644 --- a/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java +++ b/server/src/main/java/org/tattour/server/domain/order/controller/dto/response/ReadOrderSheetRes.java @@ -1,32 +1,25 @@ package org.tattour.server.domain.order.controller.dto.response; import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; -import org.tattour.server.domain.user.provider.vo.HomeUserInfo; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; -import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; -import org.tattour.server.domain.user.provider.vo.UserProfileInfo; +import org.tattour.server.domain.order.provider.vo.OrderAmountDetailRes; +import org.tattour.server.domain.user.provider.vo.UserProfileRes; @Schema(description = "결제 페이지 불러오기") @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) public class ReadOrderSheetRes { - private UserProfileInfo userProfileInfo; - private ReadOrderSheetStickerInfo readOrderSheetStickerInfo; - - private OrderAmountInfo orderAmountInfo; - - private UserPointAfterOrderInfo userPointAfterOrderInfo; + private UserProfileRes userProfileRes; + private List orderSheetStickersRes; + private OrderAmountDetailRes orderAmountDetailRes; public static ReadOrderSheetRes of( - UserProfileInfo userProfileInfo, - ReadOrderSheetStickerInfo readOrderSheetStickerInfo, - OrderAmountInfo orderAmountInfo, - UserPointAfterOrderInfo userPointAfterOrderInfo) { - return new ReadOrderSheetRes(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo, - userPointAfterOrderInfo); + UserProfileRes userProfileRes, + List orderSheetStickersRes, + OrderAmountDetailRes orderAmountDetailRes) { + return new ReadOrderSheetRes(userProfileRes, orderSheetStickersRes, orderAmountDetailRes); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/OrderFacade.java b/server/src/main/java/org/tattour/server/domain/order/facade/OrderFacade.java index eb811430..e29f156d 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/OrderFacade.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/OrderFacade.java @@ -1,25 +1,20 @@ package org.tattour.server.domain.order.facade; import org.tattour.server.domain.order.controller.dto.response.ReadOrderSheetRes; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.facade.dto.request.ReadOrderSheetReq; +import org.tattour.server.domain.order.model.PurchaseRequest; +import org.tattour.server.domain.order.facade.dto.request.CreateOrderReq; import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; public interface OrderFacade { - // 결제 시트 불러오기 - ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req); + ReadOrderSheetRes readOrderSheet(int userId, PurchaseRequest purchaseRequest); - // 주문하기 - void createOrder(CreateOrderRequest req); + void order(PurchaseRequest purchaseRequest, CreateOrderReq createOrderReq); - // 유저 결제 내역 불러오기 ReadUserOrderHistoryListRes readOrderHistoryByUserId(Integer userId); - // 모든 결제내역 불러오기 ReadOrderHistoryListRes readOrderHistoryOnPage(int page); - // 주문내역 상태 변경 void updateOrderStatus(UpdateOrderStatusReq req); } diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderReq.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderReq.java new file mode 100644 index 00000000..09a473ef --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderReq.java @@ -0,0 +1,22 @@ +package org.tattour.server.domain.order.facade.dto.request; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class CreateOrderReq { + + private int userId; + private int productAmount; + private int shippingFee; + private int totalAmount; + private String recipientName; + private String contact; + private String mailingAddress; + private String baseAddress; + private String detailAddress; +} diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderRequest.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderRequest.java deleted file mode 100644 index af86858d..00000000 --- a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/CreateOrderRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.tattour.server.domain.order.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class CreateOrderRequest { - - private Integer userId; - private Integer stickerId; - private Integer productCount; - private Integer shippingFee; - private Integer totalAmount; - private String recipientName; - private String contact; - private String mailingAddress; - private String baseAddress; - private String detailAddress; - - public static CreateOrderRequest of( - Integer userId, - Integer stickerId, - Integer productCount, - Integer shippingFee, - Integer totalAmount, - String recipientName, - String contact, - String mailingAddress, - String baseAddress, - String detailAddress) { - return new CreateOrderRequest( - userId, - stickerId, - productCount, - shippingFee, - totalAmount, - recipientName, - contact, - mailingAddress, - baseAddress, - detailAddress); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java deleted file mode 100644 index 5a59939a..00000000 --- a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/ReadOrderSheetReq.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.tattour.server.domain.order.facade.dto.request; - -import javax.validation.constraints.NotNull; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadOrderSheetReq { - - @NotNull(message = "userId is null") - private Integer userId; - @NotNull(message = "stickerId is null") - private Integer stickerId; - - @NotNull(message = "count is null") - private Integer count; - - @NotNull(message = "shippingFee is null") - private Integer shippingFee; - - public static ReadOrderSheetReq of(Integer userId, Integer stickerId, Integer count, - Integer shippingFee) { - return new ReadOrderSheetReq(userId, stickerId, count, shippingFee); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/UpdateOrderStatusReq.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/UpdateOrderStatusReq.java index d0830c07..31159825 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/UpdateOrderStatusReq.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/dto/request/UpdateOrderStatusReq.java @@ -3,7 +3,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.order.domain.OrderStatus; +import org.tattour.server.domain.order.model.OrderStatus; @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/dto/response/ReadOrderHistoryListRes.java b/server/src/main/java/org/tattour/server/domain/order/facade/dto/response/ReadOrderHistoryListRes.java index 4ed52e30..21e0713f 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/dto/response/ReadOrderHistoryListRes.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/dto/response/ReadOrderHistoryListRes.java @@ -16,7 +16,8 @@ public class ReadOrderHistoryListRes { private List orderHistoryInfoList; private OrderHistoryPageInfo orderHistoryPageInfo; - public static ReadOrderHistoryListRes of(List orderHistoryInfoList, + public static ReadOrderHistoryListRes of( + List orderHistoryInfoList, OrderHistoryPageInfo orderHistoryPageInfo) { return new ReadOrderHistoryListRes(orderHistoryInfoList, orderHistoryPageInfo); } diff --git a/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java index 94cf6d6a..059a0f27 100644 --- a/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/facade/impl/OrderFacadeImpl.java @@ -1,34 +1,33 @@ package org.tattour.server.domain.order.facade.impl; -import java.util.Objects; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.cart.service.CartService; +import org.tattour.server.domain.order.controller.dto.response.OrderSheetStickerRes; import org.tattour.server.domain.order.controller.dto.response.ReadOrderSheetRes; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.domain.OrderStatus; import org.tattour.server.domain.order.facade.OrderFacade; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.facade.dto.request.ReadOrderSheetReq; +import org.tattour.server.domain.order.facade.dto.request.CreateOrderReq; import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes; -import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; -import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; +import org.tattour.server.domain.order.model.OrderAmount; +import org.tattour.server.domain.order.model.OrderHistory; +import org.tattour.server.domain.order.model.OrderStatus; +import org.tattour.server.domain.order.model.OrderedProduct; +import org.tattour.server.domain.order.model.PurchaseRequest; import org.tattour.server.domain.order.provider.impl.OrderProviderImpl; +import org.tattour.server.domain.order.provider.vo.OrderAmountDetailRes; +import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo; import org.tattour.server.domain.order.service.impl.OrderServiceImpl; -import org.tattour.server.domain.point.service.impl.PointServiceImpl; -import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; +import org.tattour.server.domain.user.model.User; import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.provider.vo.UserProfileInfo; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; +import org.tattour.server.domain.user.provider.vo.UserProfileRes; import org.tattour.server.global.exception.BusinessException; import org.tattour.server.global.exception.ErrorType; import org.tattour.server.global.util.EntityDtoMapper; @@ -38,91 +37,86 @@ @RequiredArgsConstructor public class OrderFacadeImpl implements OrderFacade { + public final static int SHIPPING_FEE = 3000; + private final OrderProviderImpl orderProvider; private final OrderServiceImpl orderService; + private final CartService cartService; private final StickerProviderImpl stickerProvider; private final UserProviderImpl userProvider; - private final UserServiceImpl userService; - private final PointServiceImpl pointService; private final DiscordMessageService discordMessageService; + //todo : 배달 지역별로 배송비 책정하기? @Override @Transactional - public ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req) { - User user = userProvider.readUserById(req.getUserId()); - Sticker sticker = stickerProvider.getById(req.getStickerId()); - - // 유저 프로필 정보 - UserProfileInfo userProfileInfo = userProvider.readUserProfileInfo(user); - - // 스티커 정보(배너이미지, 이름, 원래가격, 할인가격) + 개수 - ReadOrderSheetStickerInfo readOrderSheetStickerInfo = - stickerProvider.readOrderSheetStickerInfo(sticker); - readOrderSheetStickerInfo.setCount(req.getCount()); - - // 결제 금액 정보 - // 총 결제 금액, 총 상품 금액, 배송비 - OrderAmountInfo orderAmountInfo = - orderProvider.readOrderAmountRes( - Objects.isNull(sticker.getDiscountPrice()) - ? sticker.getPrice() - : sticker.getDiscountPrice(), - req.getCount(), - req.getShippingFee()); - - // 포인트 - // 보유 포인트, 남는 포인트 - UserPointAfterOrderInfo userPointAfterOrderInfo = - userProvider.readUserPointAfterOrderInfo( - user, - orderAmountInfo.getTotalAmount()); - - return ReadOrderSheetRes.of(userProfileInfo, readOrderSheetStickerInfo, orderAmountInfo, - userPointAfterOrderInfo); + public ReadOrderSheetRes readOrderSheet(int userId, PurchaseRequest purchaseRequest) { + User user = userProvider.readUserById(userId); + StickerOrderInfo stickerOrderInfo = getStickerOrderInfo(user, purchaseRequest); + + UserProfileRes userProfileRes = + EntityDtoMapper.INSTANCE.toUserProfileInfo(user); + + List orderSheetStickersRes = + EntityDtoMapper.INSTANCE.toOrderSheetStickerRes(stickerOrderInfo); + + OrderAmountDetailRes orderAmountDetailRes = + EntityDtoMapper.INSTANCE.toOrderAmountRes(stickerOrderInfo, SHIPPING_FEE); + + return ReadOrderSheetRes.of(userProfileRes, orderSheetStickersRes, orderAmountDetailRes); + } + + private StickerOrderInfo getStickerOrderInfo(User user, PurchaseRequest purchaseRequest) { + if (purchaseRequest.isCartPurchase()) { + List carts = cartService.findByUser(user); + if (carts.isEmpty()) { + throw new BusinessException(ErrorType.NOT_FOUND_CARTS_EXCEPTION); + } + return getCartStickersOrderInfo(carts); + } + + return getSingleStickerOrderInfo(purchaseRequest.getStickerId(), + purchaseRequest.getCount()); + } + + private StickerOrderInfo getSingleStickerOrderInfo(int stickerId, int count) { + return stickerProvider.getStickerOrderInfoFromOrder(stickerId, count); + } + + private StickerOrderInfo getCartStickersOrderInfo(List carts) { + return stickerProvider.getStickerOrderInfoFromCart(carts); } @Override @Transactional - public void createOrder(CreateOrderRequest req) { - User user = userProvider.readUserById(req.getUserId()); - - if (userProvider.isUserPointLack(user, req.getTotalAmount())) { - throw new BusinessException(ErrorType.LACK_OF_POINT_EXCEPTION); + public void order(PurchaseRequest purchaseRequest, CreateOrderReq orderReq) { + User user = userProvider.readUserById(orderReq.getUserId()); + StickerOrderInfo stickerOrderInfo = getStickerOrderInfo(user, purchaseRequest); + OrderAmount orderAmount = OrderAmount.calculate( + stickerOrderInfo, + orderReq.getTotalAmount(), + orderReq.getShippingFee()); + + OrderHistory orderHistory = orderService.saveOrder( + OrderHistory.builder() + .productAmount(orderAmount.getProductAmount()) + .shippingFee(orderAmount.getShippingFee()) + .totalAmount(orderAmount.getTotalAmount()) + .recipientName(orderReq.getRecipientName()) + .contact(orderReq.getContact()) + .mailingAddress(orderReq.getMailingAddress()) + .baseAddress(orderReq.getBaseAddress()) + .detailAddress(orderReq.getDetailAddress()) + .user(user) + .build()); + + List orderedProducts = orderService.saveOrderedProducts(orderHistory, + stickerOrderInfo); + + if (purchaseRequest.isCartPurchase()) { + cartService.deleteAllByUserId(user); } - // 주문내역 생성 - Sticker sticker = stickerProvider.getById(req.getStickerId()); - Order order = orderService.saveOrder( - Order.of( - sticker.getName(), - sticker.getSize(), - sticker.getMainImageUrl(), - sticker.getPrice(), - req.getProductCount(), - req.getShippingFee(), - req.getTotalAmount(), - req.getRecipientName(), - req.getContact(), - req.getMailingAddress(), - req.getBaseAddress(), - req.getDetailAddress(), - user, - sticker)); - - // userPoint 수정 - userService.updateUserPoint(user, -req.getTotalAmount()); - - // 포인트 로그 저장 - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.PURCHASE, - null, - -req.getTotalAmount(), - user.getPoint(), - user - )); - - discordMessageService.sendOrderStickerMessage(order); + discordMessageService.sendOrderStickerMessage(orderHistory, orderedProducts); } @Override @@ -133,7 +127,7 @@ public ReadUserOrderHistoryListRes readOrderHistoryByUserId(Integer userId) { @Override public ReadOrderHistoryListRes readOrderHistoryOnPage(int page) { - Page orderHistoryInfoPage = orderProvider.readOrderHistoryByPage(page); + Page orderHistoryInfoPage = orderProvider.readOrderHistoryByPage(page); return ReadOrderHistoryListRes.of( EntityDtoMapper.INSTANCE.toOrderHistoryInfoPage(orderHistoryInfoPage), @@ -144,34 +138,18 @@ public ReadOrderHistoryListRes readOrderHistoryOnPage(int page) { } @Override + @Transactional public void updateOrderStatus(UpdateOrderStatusReq req) { - Order order = orderProvider.readOrderById(req.getOrderId()); - User user = userProvider.readUserById(order.getUser().getId()); - - // 주문취소일 경우 - if (req.getOrderStatus().equals(OrderStatus.CANCEL)) { - if (!order.getOrderStatus().equals(OrderStatus.CANCEL)) { - // 상태 변경 - order.setOrderStatus(req.getOrderStatus()); - orderService.saveOrder(order); - - // 유저 포인트 변경 - userService.updateUserPoint(user, order.getTotalAmount()); - - // 포인트 로그 남기기 - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.CANCEL_PURCHASE, - order.getSticker().getName(), - order.getTotalAmount(), - user.getPoint(), - user)); - } else { + OrderHistory orderHistory = orderProvider.readOrderHistoryById(req.getOrderId()); + OrderStatus requestedStatus = req.getOrderStatus(); + + if (orderHistory.getOrderStatus().equals(requestedStatus)) { + if (requestedStatus.equals(OrderStatus.CANCEL)) { throw new BusinessException(ErrorType.ALREADY_CANCELED_ORDER_HISTORY_EXCEPTION); } - } else { - order.setOrderStatus(req.getOrderStatus()); - orderService.saveOrder(order); } + + orderHistory.setOrderStatus(req.getOrderStatus()); + orderService.saveOrder(orderHistory); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/model/OrderAmount.java b/server/src/main/java/org/tattour/server/domain/order/model/OrderAmount.java new file mode 100644 index 00000000..787a0232 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/model/OrderAmount.java @@ -0,0 +1,39 @@ +package org.tattour.server.domain.order.model; + +import lombok.Getter; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; +import org.tattour.server.global.exception.BusinessException; +import org.tattour.server.global.exception.ErrorType; + +@Getter +public class OrderAmount { + + private final int productAmount; + private final int shippingFee; + private final int totalAmount; + + private OrderAmount(StickerOrderInfo stickerOrderInfo, int requestTotalAmount, + int shippingFee) { + int totalAmount = stickerOrderInfo.calculateTotalAmount(shippingFee); + validate(requestTotalAmount, totalAmount); + + this.productAmount = stickerOrderInfo.calculateProductAmount(); + this.shippingFee = shippingFee; + this.totalAmount = totalAmount; + } + + public static OrderAmount calculate(StickerOrderInfo stickerOrderInfo, int requestTotalAmount, + int shippingFee) { + return new OrderAmount(stickerOrderInfo, requestTotalAmount, shippingFee); + } + + private void validate(int requestTotalAmount, int totalAmount) { + if (isTotalAmountNotMatch(requestTotalAmount, totalAmount)) { + throw new BusinessException(ErrorType.ORDER_AMOUNT_NOT_MATCH_EXCEPTION); + } + } + + private boolean isTotalAmountNotMatch(int requestTotalAmount, int totalAmount) { + return requestTotalAmount != totalAmount; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/order/domain/Order.java b/server/src/main/java/org/tattour/server/domain/order/model/OrderHistory.java similarity index 54% rename from server/src/main/java/org/tattour/server/domain/order/domain/Order.java rename to server/src/main/java/org/tattour/server/domain/order/model/OrderHistory.java index 849a6026..4d359c3d 100644 --- a/server/src/main/java/org/tattour/server/domain/order/domain/Order.java +++ b/server/src/main/java/org/tattour/server/domain/order/model/OrderHistory.java @@ -1,5 +1,6 @@ -package org.tattour.server.domain.order.domain; +package org.tattour.server.domain.order.model; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -10,29 +11,27 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.user.domain.User; +import org.tattour.server.domain.user.model.User; @Entity @Table(name = "order_history") @DynamicInsert @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Order { +public class OrderHistory { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; - private String productName; - private String productSize; - @Column(columnDefinition = "text") - private String productImageUrl; + private Integer productAmount; - private Integer productCount; private Integer shippingFee; private Integer totalAmount; private String recipientName; @@ -53,22 +52,18 @@ public class Order { @Column(columnDefinition = "tinyint") private Boolean state; + @OneToMany(mappedBy = "orderHistory") + private List orderedProducts; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") private User user; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "sticker_id") - private Sticker sticker; - - public Order(String productName, String productSize, String productImageUrl, Integer productAmount, - Integer productCount, Integer shippingFee, Integer totalAmount, String recipientName, + @Builder + public OrderHistory(Integer productAmount, Integer shippingFee, Integer totalAmount, + String recipientName, String contact, String mailingAddress, String baseAddress, String detailAddress, - User user, Sticker sticker) { - this.productName = productName; - this.productSize = productSize; - this.productImageUrl = productImageUrl; - this.productCount = productCount; + User user) { this.productAmount = productAmount; this.shippingFee = shippingFee; this.totalAmount = totalAmount; @@ -78,19 +73,9 @@ public Order(String productName, String productSize, String productImageUrl, Int this.baseAddress = baseAddress; this.detailAddress = detailAddress; this.user = user; - this.sticker = sticker; - } - - public static Order of(String productName, String productSize, String productImageUrl, Integer productAmount, - Integer productCount, Integer shippingFee, Integer totalAmount, String recipientName, - String contact, String mailingAddress, String baseAddress, String detailAddress, - User user, Sticker sticker){ - return new Order(productName, productSize, productImageUrl, productCount, productAmount, - shippingFee, totalAmount, recipientName, contact, mailingAddress, baseAddress, - detailAddress, user, sticker); } - public void setOrderStatus(OrderStatus orderStatus){ + public void setOrderStatus(OrderStatus orderStatus) { this.orderStatus = orderStatus; } } diff --git a/server/src/main/java/org/tattour/server/domain/order/domain/OrderStatus.java b/server/src/main/java/org/tattour/server/domain/order/model/OrderStatus.java similarity index 88% rename from server/src/main/java/org/tattour/server/domain/order/domain/OrderStatus.java rename to server/src/main/java/org/tattour/server/domain/order/model/OrderStatus.java index 615f9236..2a84a7f2 100644 --- a/server/src/main/java/org/tattour/server/domain/order/domain/OrderStatus.java +++ b/server/src/main/java/org/tattour/server/domain/order/model/OrderStatus.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.order.domain; +package org.tattour.server.domain.order.model; import lombok.AccessLevel; import lombok.Getter; diff --git a/server/src/main/java/org/tattour/server/domain/order/model/OrderedProduct.java b/server/src/main/java/org/tattour/server/domain/order/model/OrderedProduct.java new file mode 100644 index 00000000..c4a33999 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/model/OrderedProduct.java @@ -0,0 +1,52 @@ +package org.tattour.server.domain.order.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.tattour.server.domain.sticker.model.Sticker; + +@Entity +@Table(name = "ordered_product") +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class OrderedProduct { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + private String name; + private Integer price; + private Integer count; + @Column(columnDefinition = "text") + private String mainImageUrl; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "sticker_id") + private Sticker sticker; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "order_history_id") + private OrderHistory orderHistory; + + @Builder + private OrderedProduct(String name, Integer price, Integer count, String mainImageUrl, + Sticker sticker, + OrderHistory orderHistory) { + this.name = name; + this.price = price; + this.count = count; + this.mainImageUrl = mainImageUrl; + this.sticker = sticker; + this.orderHistory = orderHistory; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/order/model/PurchaseRequest.java b/server/src/main/java/org/tattour/server/domain/order/model/PurchaseRequest.java new file mode 100644 index 00000000..dce93639 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/model/PurchaseRequest.java @@ -0,0 +1,36 @@ +package org.tattour.server.domain.order.model; + +import lombok.Getter; +import org.tattour.server.global.exception.BusinessException; +import org.tattour.server.global.exception.ErrorType; + +@Getter +public class PurchaseRequest { + private final Integer stickerId; + private final Integer count; + + private PurchaseRequest(Integer stickerId, Integer count) { + validate(); + this.stickerId = stickerId; + this.count = count; + } + + private void validate() { + if (!isValidRequest()) { + throw new BusinessException(ErrorType.INVALID_ORDERSHEET_ARGUMENT_EXCEPTION); + } + } + + private boolean isValidRequest() { + return (stickerId == null && count == null) || (stickerId != null && count != null); + } + + + public static PurchaseRequest of(Integer stickerId, Integer count) { + return new PurchaseRequest(stickerId, count); + } + + public boolean isCartPurchase() { + return stickerId == null && count == null; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/order/provider/OrderProvider.java b/server/src/main/java/org/tattour/server/domain/order/provider/OrderProvider.java index 3cea6e3a..d46eb26a 100644 --- a/server/src/main/java/org/tattour/server/domain/order/provider/OrderProvider.java +++ b/server/src/main/java/org/tattour/server/domain/order/provider/OrderProvider.java @@ -2,31 +2,17 @@ import java.util.List; import org.springframework.data.domain.Page; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; +import org.tattour.server.domain.order.model.OrderHistory; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo; public interface OrderProvider { - // 결제 내역 1개 가져오기 - Order readOrderById(int orderId); + OrderHistory readOrderHistoryById(int orderHistoryId); - // 페이지로 결제 내역 불러오기 - Page readOrderHistoryByPage(int page); + Page readOrderHistoryByPage(int page); - // 유저 결제 내역 불러오기 ReadUserOrderHistoryListRes readOrderHistoryByUserId(int userId); - // 기준날짜로 결제 내역 불러오기 List readOrderHistoryAfterDate(int userId, String date); - - // 결제 금액정보 가져오기 - OrderAmountInfo readOrderAmountRes(int price, int count, int shippingFee); - - // 상품 금액 계산 - int calculateProductAmount(int price, int count); - - // 총 결제금액 계산 - int calculateTotalAmount(int productAmount, int shippingFee); } diff --git a/server/src/main/java/org/tattour/server/domain/order/provider/impl/OrderProviderImpl.java b/server/src/main/java/org/tattour/server/domain/order/provider/impl/OrderProviderImpl.java index e5230d7b..bbc81237 100644 --- a/server/src/main/java/org/tattour/server/domain/order/provider/impl/OrderProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/provider/impl/OrderProviderImpl.java @@ -6,11 +6,10 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo; -import org.tattour.server.domain.order.provider.vo.OrderAmountInfo; -import org.tattour.server.domain.order.provider.OrderProvider; +import org.tattour.server.domain.order.model.OrderHistory; import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; +import org.tattour.server.domain.order.provider.OrderProvider; +import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo; import org.tattour.server.domain.order.repository.impl.OrderRepositoryImpl; import org.tattour.server.global.exception.BusinessException; import org.tattour.server.global.exception.ErrorType; @@ -23,13 +22,13 @@ public class OrderProviderImpl implements OrderProvider { private final OrderRepositoryImpl orderRepository; @Override - public Order readOrderById(int orderId) { - return orderRepository.findById(orderId) + public OrderHistory readOrderHistoryById(int orderHistoryId) { + return orderRepository.findById(orderHistoryId) .orElseThrow(() -> new BusinessException(ErrorType.NOT_FOUND_ORDER_HISTORY)); } @Override - public Page readOrderHistoryByPage(int page) { + public Page readOrderHistoryByPage(int page) { return orderRepository.findAll( PageRequest.of( page - 1, @@ -49,27 +48,9 @@ public ReadUserOrderHistoryListRes readOrderHistoryByUserId(int userId) { @Override public List readOrderHistoryAfterDate(int userId, String date) { return EntityDtoMapper.INSTANCE - .toGetUserOrderHistoryListRes( - orderRepository.findAllByUser_IdAndCreatedAtAfter( - userId, - date)); - } - - @Override - public OrderAmountInfo readOrderAmountRes(int price, int count, int shippingFee) { - int productAmount = calculateProductAmount(price, count); - int totalAmount = calculateTotalAmount(productAmount, shippingFee); - - return OrderAmountInfo.of(totalAmount, productAmount, shippingFee); - } - - @Override - public int calculateProductAmount(int price, int count) { - return price * count; - } - - @Override - public int calculateTotalAmount(int productAmount, int shippingFee) { - return productAmount + shippingFee; + .toGetUserOrderHistoryListRes( + orderRepository.findAllByUser_IdAndCreatedAtAfter( + userId, + date)); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountDetailRes.java similarity index 70% rename from server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java rename to server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountDetailRes.java index 38109d0a..8a3a97bb 100644 --- a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountInfo.java +++ b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderAmountDetailRes.java @@ -7,8 +7,7 @@ @Schema(description = "결제 금액 정보") @Getter @AllArgsConstructor -public class OrderAmountInfo { - +public class OrderAmountDetailRes { @Schema(description = "총 결제금액", example = "12000") private Integer totalAmount; @@ -19,8 +18,7 @@ public class OrderAmountInfo { @Schema(description = "배송비", example = "3000") private Integer shippingFee; - public static OrderAmountInfo of(Integer totalAmount, Integer productAmount, - Integer shippingFee) { - return new OrderAmountInfo(totalAmount, productAmount, shippingFee); + public static OrderAmountDetailRes of(Integer totalAmount, Integer productAmount, Integer shippingFee) { + return new OrderAmountDetailRes(totalAmount, productAmount, shippingFee); } } diff --git a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderHistoryInfo.java b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderHistoryInfo.java index 1a818de9..ec089aa7 100644 --- a/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderHistoryInfo.java +++ b/server/src/main/java/org/tattour/server/domain/order/provider/vo/OrderHistoryInfo.java @@ -1,10 +1,8 @@ package org.tattour.server.domain.order.provider.vo; -import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.tattour.server.domain.order.domain.OrderStatus; @Getter @Setter diff --git a/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderRepositoryImpl.java index cbd82806..b0ffc789 100644 --- a/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderRepositoryImpl.java @@ -3,13 +3,13 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import org.tattour.server.domain.order.domain.Order; +import org.tattour.server.domain.order.model.OrderHistory; @Repository -public interface OrderRepositoryImpl extends JpaRepository { +public interface OrderRepositoryImpl extends JpaRepository { - List findAllByUser_Id(Integer userId); + List findAllByUser_Id(Integer userId); // userId와 기준 시간 이후 행 가져오기 - List findAllByUser_IdAndCreatedAtAfter(Integer userId, String date); + List findAllByUser_IdAndCreatedAtAfter(Integer userId, String date); } diff --git a/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderedProductRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderedProductRepositoryImpl.java new file mode 100644 index 00000000..38d2d77d --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/order/repository/impl/OrderedProductRepositoryImpl.java @@ -0,0 +1,9 @@ +package org.tattour.server.domain.order.repository.impl; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.tattour.server.domain.order.model.OrderedProduct; + +@Repository +public interface OrderedProductRepositoryImpl extends JpaRepository { +} diff --git a/server/src/main/java/org/tattour/server/domain/order/service/OrderService.java b/server/src/main/java/org/tattour/server/domain/order/service/OrderService.java index 882d71f3..fa997b18 100644 --- a/server/src/main/java/org/tattour/server/domain/order/service/OrderService.java +++ b/server/src/main/java/org/tattour/server/domain/order/service/OrderService.java @@ -1,12 +1,14 @@ package org.tattour.server.domain.order.service; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.domain.OrderStatus; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; +import java.util.List; +import org.tattour.server.domain.order.model.OrderHistory; +import org.tattour.server.domain.order.model.OrderedProduct; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; public interface OrderService { - // 결제하기 - Order saveOrder(Order order); + OrderHistory saveOrder(OrderHistory orderHistory); + + List saveOrderedProducts(OrderHistory orderHistory, + StickerOrderInfo stickerOrderInfo); } diff --git a/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java b/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java index ccc88c74..8fd53322 100644 --- a/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/order/service/impl/OrderServiceImpl.java @@ -1,33 +1,47 @@ package org.tattour.server.domain.order.service.impl; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.order.facade.dto.request.CreateOrderRequest; -import org.tattour.server.domain.order.provider.impl.OrderProviderImpl; +import org.tattour.server.domain.order.model.OrderHistory; +import org.tattour.server.domain.order.model.OrderedProduct; import org.tattour.server.domain.order.repository.impl.OrderRepositoryImpl; +import org.tattour.server.domain.order.repository.impl.OrderedProductRepositoryImpl; import org.tattour.server.domain.order.service.OrderService; -import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq; -import org.tattour.server.domain.point.service.impl.PointServiceImpl; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl; -import org.tattour.server.domain.order.domain.OrderStatus; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; @Service @RequiredArgsConstructor public class OrderServiceImpl implements OrderService { private final OrderRepositoryImpl orderRepository; + private final OrderedProductRepositoryImpl orderedProductRepository; @Override @Transactional - public Order saveOrder(Order order) { - return orderRepository.save(order); + public OrderHistory saveOrder(OrderHistory orderHistory) { + return orderRepository.save(orderHistory); + } + + @Override + public List saveOrderedProducts(OrderHistory orderHistory, + StickerOrderInfo stickerOrderInfo) { + List orderedProducts = stickerOrderInfo.getStickerOrderInfos() + .entrySet() + .stream() + .map(entry -> OrderedProduct.builder() + .name(entry.getKey().getName()) + .price(entry.getKey().getPrice()) + .count(entry.getValue()) + .mainImageUrl(entry.getKey().getMainImageUrl()) + .sticker(entry.getKey()) + .orderHistory(orderHistory) + .build()) + .collect(Collectors.toUnmodifiableList()); + + orderedProductRepository.saveAll(orderedProducts); + return orderedProducts; } } diff --git a/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java b/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java deleted file mode 100644 index 9191a12d..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/dao/PointDao.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.tattour.server.domain.point.dao; - -import java.util.ArrayList; -import java.util.List; -import javax.sql.DataSource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.order.domain.OrderStatus; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; - -@Repository -public class PointDao { - - private final JdbcTemplate jdbcTemplate; - - public PointDao(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - // 조건에 따라 유저 포인트 충전 요청 내역 가져오기 - public List findPointChargeRequestResList(Integer userId, - Boolean isCompleted) { - String query = - "SELECT * " - + "FROM point_charge_request " - + "WHERE 1=1 "; - List params = new ArrayList<>(); - - if (userId != null) { - params.add(userId); - query += "AND user_id = ? "; - } - - if (isCompleted != null) { - params.add(isCompleted); - query += "AND is_completed = ? "; - } - - return jdbcTemplate.query(query, - (rs, rownum) -> PointChargeRequestInfo.builder() - .id(rs.getInt("id")) - .userId(rs.getInt("user_id")) - .chargeAmount(rs.getInt("charge_amount")) - .transferredAmount(rs.getInt("transferred_amount")) - .isDeposited(rs.getBoolean("is_deposited")) - .isAmountMatched(rs.getBoolean("is_amount_matched")) - .isCompleted(rs.getBoolean("is_completed")) - .createdAt(rs.getString("created_at")) - .lastUpdatedAt(rs.getString("last_updated_at")) - .state(rs.getBoolean("state")) - .build(), - params.toArray()); - } - - // 조건에 따라 포인트 로그 불러오기 - public List findPointLogResList(Integer userId, String category) { - String query = - "SELECT * FROM user_point_log " - + "WHERE 1=1 "; - List params = new ArrayList<>(); - - if (userId != null) { - params.add(userId); - query += "AND user_id = ? "; - } - - if (category != null) { - params.add(category); - query += "AND title = ? "; - } - - return jdbcTemplate.query(query, - (rs, rownum) -> PointLogInfo.builder() - .id(rs.getInt("id")) - .userId(rs.getInt("user_id")) - .title(PointLogCategory.valueOf(rs.getString("title")).getValue()) - .content(rs.getString("content")) - .amount(rs.getInt("amount")) - .resultPointAmount(rs.getInt("result_point_amount")) - .createdAt(rs.getString("created_at")) - .state(rs.getBoolean("state")) - .build(), - params.toArray()); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java b/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java deleted file mode 100644 index 70733dba..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/PointChargeRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.user.domain.User; - -@Entity -@DynamicInsert -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PointChargeRequest { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - private Integer chargeAmount; - private Integer transferredAmount; - @Column(columnDefinition = "tinyint") - private Boolean isDeposited; - @Column(columnDefinition = "tinyint") - private Boolean isAmountMatched; - @Column(columnDefinition = "tinyint") - private Boolean isApproved; - @Column(columnDefinition = "tinyint") - private Boolean isCompleted; - @Column(columnDefinition = "Timestamp") - private String createdAt; - @Column(columnDefinition = "Timestamp") - private String lastUpdatedAt; - @Column(columnDefinition = "tinyint") - private Boolean state; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - private PointChargeRequest(User user, Integer chargeAmount) { - this.user = user; - this.chargeAmount = chargeAmount; - } - - public static PointChargeRequest of(User user, Integer chargeAmount) { - return new PointChargeRequest(user, chargeAmount); - } - - public void setProperties(Integer transferredAmount, Boolean isDeposited, - Boolean isAmountMatched, Boolean isApproved, Boolean isCompleted) { - this.transferredAmount = transferredAmount; - this.isDeposited = isDeposited; - this.isAmountMatched = isAmountMatched; - this.isApproved = isApproved; - this.isCompleted = isCompleted; - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java b/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java deleted file mode 100644 index f9282f9a..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/PointLogCategory.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import java.util.Arrays; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public enum PointLogCategory { - PURCHASE("상품 구매"), - APPLY_CUSTOM("커스텀 신청"), - CANCEL_PURCHASE("결제 취소"), - REQUEST_CHARGE("포인트 충전 요청"), - CANCEL_CHARGE("충전 취소"), - ; - - private final String value; - - public static PointLogCategory fromValue(String value) { - return Arrays.stream(PointLogCategory.values()) - .filter(category -> category.value.equals(value)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException( - "입력한 value와 일치하는 Enum 타입이 없습니다: " + value)); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java b/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java deleted file mode 100644 index a379008a..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/domain/UserPointLog.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.tattour.server.domain.point.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.DynamicInsert; -import org.tattour.server.domain.user.domain.User; - -@Entity -@DynamicInsert -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserPointLog { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - @Column(name = "title") - @Enumerated(EnumType.STRING) - private PointLogCategory pointLogCategory; - private String content; - @Column(columnDefinition = "Timestamp") - private String createdAt; - private Integer amount; - private Integer resultPointAmount; - @Column(columnDefinition = "tinyint") - private Boolean state; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - private UserPointLog(PointLogCategory pointLogCategory, String content, Integer amount, - Integer resultPointAmount, User user) { - this.pointLogCategory = pointLogCategory; - this.content = content; - this.amount = amount; - this.resultPointAmount = resultPointAmount; - this.user = user; - } - - public static UserPointLog of(PointLogCategory pointLogCategory, String content, Integer amount, - Integer resultPointAmount, User user) { - return new UserPointLog(pointLogCategory, content, amount, resultPointAmount, user); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java b/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java deleted file mode 100644 index 8bb5941f..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/PointFacade.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.tattour.server.domain.point.facade; - -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.CreatePointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; - -public interface PointFacade { - // 포인트 충전 요청 - void createPointChargeRequest(CreatePointChargeRequestReq req); - - // 포인트 충전 요청 신청 내역 가져오기 - ReadPointChargeRequestListRes readPointChargeRequest(ReadPointChargeRequestListReq req); - - // 포인트 충전 요청 확인 - ConfirmPointChargeRes confirmPointChargeRequest(ConfirmPointChargeReq req); - - // 포인트 충전 요청 취소 - void cancelPointChargeRequest(CancelPointChargeRequestReq req); - - // 포인트 로그 불러오기 - ReadPointLogListRes readPointLog(ReadPointLogListReq req); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java deleted file mode 100644 index 65eaf79c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ConfirmPointChargeReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ConfirmPointChargeReq { - private int id; - private int userId; - private int transferredAmount; - - public static ConfirmPointChargeReq of(int id, int userId, int transferredAmount) { - return new ConfirmPointChargeReq(id, userId, transferredAmount); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java deleted file mode 100644 index 5414713c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/CreatePointChargeRequestReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class CreatePointChargeRequestReq { - - private int userId; - private int chargeAmount; - - public static CreatePointChargeRequestReq of(int userId, int chargeAmount) { - return new CreatePointChargeRequestReq(userId, chargeAmount); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java deleted file mode 100644 index a1f6fd1d..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointChargeRequestListReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointChargeRequestListReq { - private Integer userId; - private Boolean isCompleted; - public static ReadPointChargeRequestListReq of(Integer userId, Boolean isCompleted){ - return new ReadPointChargeRequestListReq(userId, isCompleted); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java deleted file mode 100644 index 4e8ebc86..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/request/ReadPointLogListReq.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.request; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.tattour.server.domain.point.domain.PointLogCategory; - -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointLogListReq { - Integer userId; - PointLogCategory category; - - public static ReadPointLogListReq of(Integer userId, PointLogCategory category){ - return new ReadPointLogListReq(userId, category); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java deleted file mode 100644 index a21b390b..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ConfirmPointChargeRes.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; -import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; -import org.tattour.server.domain.user.provider.vo.UserContactInfo; - -@Schema(description = "송금 금액이 다를 경우 user 정보 Response") -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ConfirmPointChargeRes { - - // 유저 정보 - UserContactInfo userContactInfo; - // 포인트 충전 내역 - ReadPointChargeRequestListRes readPointChargeRequestListRes; - // 구매 내역 - ReadUserOrderHistoryListRes orderHistoryListRes; - // 커스텀 신청내역 - ReadCustomSummaryListRes readCustomSummaryListRes; - - public static ConfirmPointChargeRes of( - UserContactInfo userContactInfo, - ReadPointChargeRequestListRes readPointChargeRequestListRes, - ReadUserOrderHistoryListRes readUserOrderHistoryListRes, - ReadCustomSummaryListRes readCustomSummaryListRes) { - return new ConfirmPointChargeRes(userContactInfo, readPointChargeRequestListRes, - readUserOrderHistoryListRes, readCustomSummaryListRes); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java deleted file mode 100644 index 8a3607ad..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointChargeRequestListRes.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.List; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.point.provider.vo.PointChargeRequestInfo; - -@Schema(description = "포인트 충전 요청 내역 리스트 Response") -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointChargeRequestListRes { - - List pointChargeRequestInfoList; - - public static ReadPointChargeRequestListRes of( - List pointChargeRequestInfoList) { - return new ReadPointChargeRequestListRes(pointChargeRequestInfoList); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java b/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java deleted file mode 100644 index 9be910fe..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/dto/response/ReadPointLogListRes.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.tattour.server.domain.point.facade.dto.response; - -import java.util.List; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; - -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ReadPointLogListRes { - - List pointLogInfoList; - - public static ReadPointLogListRes of(List pointLogInfoList) { - return new ReadPointLogListRes(pointLogInfoList); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java deleted file mode 100644 index f8a50847..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/facade/impl/PointFacadeImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.tattour.server.domain.point.facade.impl; - -import java.util.Objects; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.custom.facade.dto.response.ReadCustomSummaryListRes; -import org.tattour.server.domain.custom.provider.CustomProvider; -import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes; -import org.tattour.server.domain.order.provider.OrderProvider; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.facade.PointFacade; -import org.tattour.server.domain.point.facade.dto.request.ConfirmPointChargeReq; -import org.tattour.server.domain.point.facade.dto.request.CreatePointChargeRequestReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointChargeRequestListReq; -import org.tattour.server.domain.point.facade.dto.request.ReadPointLogListReq; -import org.tattour.server.domain.point.facade.dto.response.ConfirmPointChargeRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.facade.dto.response.ReadPointLogListRes; -import org.tattour.server.domain.point.provider.PointProvider; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.UserProvider; -import org.tattour.server.domain.user.provider.vo.UserContactInfo; -import org.tattour.server.domain.user.service.UserService; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; -import org.tattour.server.global.util.EntityDtoMapper; -import org.tattour.server.infra.discord.service.DiscordMessageService; - -@Service -@RequiredArgsConstructor -public class PointFacadeImpl implements PointFacade { - - private final PointService pointService; - private final PointProvider pointProvider; - private final UserService userService; - private final UserProvider userProvider; - private final CustomProvider customProvider; - private final OrderProvider orderProvider; - private final DiscordMessageService discordMessageService; - - - @Override - public void createPointChargeRequest(CreatePointChargeRequestReq req) { - User user = userProvider.readUserById(req.getUserId()); - - pointService.savePointChargeRequest(PointChargeRequest.of(user, req.getChargeAmount())); - userService.updateUserPoint(user, req.getChargeAmount()); - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.REQUEST_CHARGE, - null, - req.getChargeAmount(), - user.getPoint(), - user)); - - discordMessageService.sendPointChargeLogMessage(user, req.getChargeAmount()); - } - - @Override - public ReadPointChargeRequestListRes readPointChargeRequest(ReadPointChargeRequestListReq req) { - return pointProvider.readAllPointChargeRequest(req.getUserId(), req.getIsCompleted()); - } - - @Override - public ConfirmPointChargeRes confirmPointChargeRequest(ConfirmPointChargeReq req) { - PointChargeRequest pointChargeRequest = pointProvider.readPointChargeRequestById( - req.getId()); - - if (!pointChargeRequest.getIsCompleted()) { - // 처리된 요청이 아니면 - if (req.getTransferredAmount() == pointChargeRequest.getChargeAmount()) { - // 송금된 값이 일치하면 - // PointChargeRequest의 상태를 변경하기 - pointService.updatePointChargeRequest(pointChargeRequest, - req.getTransferredAmount(), - true, true, true, true); - - return null; - } else { - // 일치하지 않으면 - String baseDate = pointChargeRequest.getCreatedAt(); - - // 유저 정보 - User user = userProvider.readUserById(req.getUserId()); - UserContactInfo userContactInfo = EntityDtoMapper.INSTANCE.toUserContactInfo(user); - - // 포인트 충전 내역 - ReadPointChargeRequestListRes readPointChargeRequestListRes = - pointProvider.readPointChargeRequestAfterDate(req.getUserId(), baseDate); - readPointChargeRequestListRes - .getPointChargeRequestInfoList() - .add(0, EntityDtoMapper.INSTANCE.toGetPointChargeRequestRes( - pointChargeRequest)); - - // 구매 내역 - ReadUserOrderHistoryListRes readUserOrderHistoryListRes = - ReadUserOrderHistoryListRes.of( - orderProvider.readOrderHistoryAfterDate( - req.getUserId(), - baseDate)); - - // 커스텀 신청내역 - ReadCustomSummaryListRes readCustomSummaryListRes = - ReadCustomSummaryListRes.from( - customProvider.getCustomByUserIdAfterDate( - req.getUserId(), - baseDate) - ); - - return ConfirmPointChargeRes.of(userContactInfo, - readPointChargeRequestListRes, - readUserOrderHistoryListRes, - readCustomSummaryListRes); - } - } else { - // 이미 처리된 요청이면 - throw new BusinessException(ErrorType.ALREADY_COMPLETED_POINT_CHARGE_REQUEST_EXCEPTION); - } - } - - @Override - public void cancelPointChargeRequest(CancelPointChargeRequestReq req) { - PointChargeRequest pointChargeRequest = pointProvider.readPointChargeRequestById( - req.getId()); - - if (pointChargeRequest.getIsCompleted()) { - // 이미 처리된 요청이면 반려 - throw new BusinessException(ErrorType.ALREADY_COMPLETED_POINT_CHARGE_REQUEST_EXCEPTION); - } else { - if (Objects.equals(req.getTransferredAmount(), pointChargeRequest.getChargeAmount())) { - // 송금 금액이 충전 금액이 같으면 반려 - throw new BusinessException(ErrorType.AMOUNT_MATCHED_EXCEPTION); - } else { - // PointChargeRequest의 상태를 변경하기 - pointService.updatePointChargeRequest( - pointChargeRequest, req.getTransferredAmount(), true, - false, false, true); - - // 포인트 로그 남기기 - User user = userProvider.readUserById(req.getUserId()); - int amount = pointChargeRequest.getChargeAmount(); - int resultPoint = user.getPoint() - amount; - - pointService.savePointLog( - UserPointLog.of( - PointLogCategory.CANCEL_CHARGE, - req.getReason(), - -pointChargeRequest.getChargeAmount(), - resultPoint, - user)); - - // 유저 포인트 처리 - userService.updateUserPoint(user, -amount); - } - } - } - - @Override - public ReadPointLogListRes readPointLog(ReadPointLogListReq req) { - return ReadPointLogListRes.of( - pointProvider.readPointLog(req.getUserId(), req.getCategory().name())); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java b/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java deleted file mode 100644 index 28905d08..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/PointProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.tattour.server.domain.point.provider; - -import java.util.List; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; -import org.tattour.server.domain.user.domain.User; - -public interface PointProvider { - - // id로 포인트 충전 요청 가져오기 - PointChargeRequest readPointChargeRequestById(Integer id); - - // id와 날짜로 포인트 충전 요청 가져오기 - ReadPointChargeRequestListRes readPointChargeRequestAfterDate(int userId, String date); - - // 조건에 따라 포인트 충전 요청 가져오기 - ReadPointChargeRequestListRes readAllPointChargeRequest(Integer userId, Boolean isCompleted); - - // 조건에 따라 포인트 로그 가져오기 - List readPointLog(Integer userId, String category); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java b/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java deleted file mode 100644 index 1fe57371..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/impl/PointProviderImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.tattour.server.domain.point.provider.impl; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.tattour.server.domain.point.dao.PointDao; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.provider.PointProvider; -import org.tattour.server.domain.point.facade.dto.response.ReadPointChargeRequestListRes; -import org.tattour.server.domain.point.provider.vo.PointLogInfo; -import org.tattour.server.domain.point.repository.impl.PointChargeRequestRepositoryImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; -import org.tattour.server.global.util.EntityDtoMapper; - -@Service -@RequiredArgsConstructor -public class PointProviderImpl implements PointProvider { - - private final PointDao pointDao; - private final PointChargeRequestRepositoryImpl pointChargeRequestRepository; - - @Override - public PointChargeRequest readPointChargeRequestById(Integer id) { - return pointChargeRequestRepository.findById(id) - .orElseThrow(() -> new BusinessException( - ErrorType.NOT_FOUND_POINT_CHARGE_REQUEST_EXCEPTION)); - } - - @Override - public ReadPointChargeRequestListRes readPointChargeRequestAfterDate(int userId, String date) { - return ReadPointChargeRequestListRes.of( - EntityDtoMapper.INSTANCE.toGetPointChargeRequestResList( - pointChargeRequestRepository - .findPointChargeRequestByUser_IdAndCreatedAtAfter(userId, date))); - } - - @Override - public ReadPointChargeRequestListRes readAllPointChargeRequest(Integer userId, - Boolean isCompleted) { - return ReadPointChargeRequestListRes.of( - pointDao.findPointChargeRequestResList(userId, isCompleted)); - } - - @Override - public List readPointLog(Integer userId, String category) { - return pointDao.findPointLogResList(userId, category); - } -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java b/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java deleted file mode 100644 index b57baf40..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointChargeRequestInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.tattour.server.domain.point.provider.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "포인트 충전 요청 내역 Response") -@Getter -@Setter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PointChargeRequestInfo { - - @Schema(description = "포인트 충전 요청 id") - private int id; - - @Schema(description = "user Id") - private int userId; - - @Schema(description = "충전 금액", example = "5000") - private Integer chargeAmount; - - @Schema(description = "송금된 금액", example = "3000") - private Integer transferredAmount; - - @Schema(description = "입금 여부", example = "true") - private Boolean isDeposited; - - @Schema(description = "금액 일치 여부", example = "false") - private Boolean isAmountMatched; - - @Schema(description = "", example = "") - private Boolean isApproved; - - @Schema(description = "", example = "") - private Boolean isCompleted; - - @Schema(description = "", example = "") - private String createdAt; - - @Schema(description = "", example = "") - private String lastUpdatedAt; - - @Schema(description = "", example = "") - private Boolean state; -} diff --git a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java b/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java deleted file mode 100644 index a34ec14c..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/provider/vo/PointLogInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.tattour.server.domain.point.provider.vo; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PointLogInfo { - - private int id; - private int userId; - private String title; - private String content; - private Integer amount; - private int resultPointAmount; - private String createdAt; - private Boolean state; -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java b/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java deleted file mode 100644 index ad68d5e6..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/PointChargeRequestRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.tattour.server.domain.point.repository; - -public interface PointChargeRequestRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java b/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java deleted file mode 100644 index bf219d4f..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/UserPointLogRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.tattour.server.domain.point.repository; - -public interface UserPointLogRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java deleted file mode 100644 index 88d3db17..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/impl/PointChargeRequestRepositoryImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.tattour.server.domain.point.repository.impl; - -import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.point.domain.PointChargeRequest; - -@Repository -public interface PointChargeRequestRepositoryImpl extends - JpaRepository { - - List findPointChargeRequestByUser_IdAndCreatedAtAfter(Integer userId, - String date); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java deleted file mode 100644 index 4e6c1bec..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/repository/impl/UserPointLogRepositoryImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.tattour.server.domain.point.repository.impl; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import org.tattour.server.domain.point.domain.UserPointLog; - -@Repository -public interface UserPointLogRepositoryImpl extends JpaRepository { - -} diff --git a/server/src/main/java/org/tattour/server/domain/point/service/PointService.java b/server/src/main/java/org/tattour/server/domain/point/service/PointService.java deleted file mode 100644 index 40a6c3c6..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/service/PointService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.tattour.server.domain.point.service; - -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.UserPointLog; - -public interface PointService { - - void savePointChargeRequest(PointChargeRequest pointChargeRequest); - - void savePointLog(UserPointLog userPointLog); - - // TODO : 삭제하기 - void updatePointChargeRequest(PointChargeRequest pointChargeRequest, int transferredAmount, - boolean isDeposited, boolean isAmountMatched, boolean isApproved, boolean isCompleted); -} diff --git a/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java b/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java deleted file mode 100644 index 63e3b2c8..00000000 --- a/server/src/main/java/org/tattour/server/domain/point/service/impl/PointServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.tattour.server.domain.point.service.impl; - -import java.util.Objects; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.tattour.server.domain.admin.controller.dto.request.CancelPointChargeRequestReq; -import org.tattour.server.domain.point.domain.PointChargeRequest; -import org.tattour.server.domain.point.domain.PointLogCategory; -import org.tattour.server.domain.point.domain.UserPointLog; -import org.tattour.server.domain.point.provider.impl.PointProviderImpl; -import org.tattour.server.domain.point.repository.impl.PointChargeRequestRepositoryImpl; -import org.tattour.server.domain.point.repository.impl.UserPointLogRepositoryImpl; -import org.tattour.server.domain.point.service.PointService; -import org.tattour.server.domain.user.domain.User; -import org.tattour.server.domain.user.provider.impl.UserProviderImpl; -import org.tattour.server.domain.user.service.impl.UserServiceImpl; -import org.tattour.server.global.exception.BusinessException; -import org.tattour.server.global.exception.ErrorType; - -@Service -@RequiredArgsConstructor -public class PointServiceImpl implements PointService { - - private final PointChargeRequestRepositoryImpl pointChargeRequestRepository; - private final UserPointLogRepositoryImpl userPointLogRepository; - private final UserProviderImpl userProvider; - private final UserServiceImpl userService; - private final PointProviderImpl pointProvider; - - @Override - @Transactional - public void savePointChargeRequest(PointChargeRequest pointChargeRequest) { - pointChargeRequestRepository.save(pointChargeRequest); - } - - @Override - @Transactional - public void savePointLog(UserPointLog userPointLog) { - userPointLogRepository.save(userPointLog); - } - - @Override - @Transactional - public void updatePointChargeRequest(PointChargeRequest pointChargeRequest, - int transferredAmount, - boolean isDeposited, boolean isAmountMatched, boolean isApproved, boolean isCompleted) { - pointChargeRequest.setProperties(transferredAmount, isDeposited, isAmountMatched, - isApproved, isCompleted); - - pointChargeRequestRepository.save(pointChargeRequest); - } -} - - - diff --git a/server/src/main/java/org/tattour/server/domain/search/facade/impl/SearchFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/search/facade/impl/SearchFacadeImpl.java index 3466d811..2fee11dc 100644 --- a/server/src/main/java/org/tattour/server/domain/search/facade/impl/SearchFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/search/facade/impl/SearchFacadeImpl.java @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.tattour.server.domain.search.facade.SearchFacade; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.provider.StickerProvider; import org.tattour.server.domain.sticker.facade.dto.response.ReadStickerSummaryListRes; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java b/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java index e7b50fd3..671b7cde 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java @@ -54,7 +54,7 @@ public ResponseEntity getHotCustomStickerList() { } @GetMapping("/{stickerId}") - @Operation(summary = "커스텀 스티커 상세 정보 조회", description = "스티커 아이디 받음") + @Operation(summary = "스티커 상세 정보 조회", description = "스티커 아이디 받음") @ApiResponses(value = { @ApiResponse( responseCode = "200", diff --git a/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java b/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java index a48c92ad..a70a81a4 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java @@ -11,65 +11,69 @@ @Builder(access = AccessLevel.PRIVATE) public class GetStickerForUserRes { - @Schema(description = "스티커 아이디") - private Integer id; + @Schema(description = "스티커 아이디") + private Integer id; - @Schema(description = "스티커 이름") - private String name; + @Schema(description = "스티커 이름") + private String name; - @Schema(description = "스티커 설명") - private String description; + @Schema(description = "스티커 설명") + private String description; - @Schema(description = "스티커 가격") - private Integer price; + @Schema(description = "스티커 가격") + private Integer price; - @Schema(description = "할인률", nullable = true) - private Integer discountRate; + @Schema(description = "할인률", nullable = true) + private Integer discountRate; - @Schema(description = "할인된 가격", nullable = true) - private Integer discountPrice; + @Schema(description = "할인된 가격", nullable = true) + private Integer discountPrice; - @Schema(description = "스티커 구성") - private String composition; + @Schema(description = "스티커 구성") + private String composition; - @Schema(description = "스티커 크기") - private String size; + @Schema(description = "스티커 크기") + private String size; - @Schema(description = "커스텀 스티커 여부") - private Boolean isCustom; + @Schema(description = "커스텀 스티커 여부") + private Boolean isCustom; - @Schema(description = "배송비") - private Integer shippingCost; + @Schema(description = "배송비") + private Integer shippingCost; - @Schema(description = "스티커 테마") - private List stickerThemes; + @Schema(description = "스티커 테마") + private List stickerThemes; - @Schema(description = "스티커 스타일") - private List stickerStyles; + @Schema(description = "스티커 스타일") + private List stickerStyles; - @Schema(description = "스티커 이미지") - private List images; + @Schema(description = "메인 이미지 url") + private String mainImage; - @Schema(description = "상품 좋아요 여부") - private Boolean productLiked; + @Schema(description = "상세 이미지 url 목록") + private List detailImages; + @Schema(description = "상품 좋아요 여부") + private Boolean productLiked; - public static GetStickerForUserRes from(ReadStickerForUserRes readStickerForUserRes) { - return GetStickerForUserRes.builder() - .id(readStickerForUserRes.getId()) - .name(readStickerForUserRes.getName()) - .description(readStickerForUserRes.getDescription()) - .price(readStickerForUserRes.getPrice()) - .discountRate(readStickerForUserRes.getDiscountRate()) - .discountPrice(readStickerForUserRes.getDiscountPrice()) - .composition(readStickerForUserRes.getComposition()) - .size(readStickerForUserRes.getSize()) - .isCustom(readStickerForUserRes.getIsCustom()) - .shippingCost(readStickerForUserRes.getShippingCost()) - .stickerThemes(readStickerForUserRes.getStickerThemes()) - .stickerStyles(readStickerForUserRes.getStickerStyles()) - .images(readStickerForUserRes.getImages()) - .productLiked(readStickerForUserRes.getProductLiked()) - .build(); - } + + public static GetStickerForUserRes from(ReadStickerForUserRes readStickerForUserRes) { + return GetStickerForUserRes.builder() + .id(readStickerForUserRes.getId()) + .name(readStickerForUserRes.getName()) + .description(readStickerForUserRes.getDescription()) + .price(readStickerForUserRes.getPrice()) + .discountRate(readStickerForUserRes.getDiscountRate()) + .discountPrice(readStickerForUserRes.getDiscountPrice()) + .composition(readStickerForUserRes.getComposition()) + .size(readStickerForUserRes.getSize()) + .isCustom(readStickerForUserRes.getIsCustom()) + .shippingCost(readStickerForUserRes.getShippingCost()) + .stickerThemes(readStickerForUserRes.getStickerThemes()) + .stickerStyles(readStickerForUserRes.getStickerStyles()) + .mainImage(readStickerForUserRes.getMainImage()) + .detailImages(readStickerForUserRes.getDetailImages()) + .productLiked(readStickerForUserRes.getProductLiked()) + .build(); + } } diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java index b07acc2d..0cb195a4 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java @@ -1,72 +1,75 @@ package org.tattour.server.domain.sticker.facade.dto.response; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.sticker.model.StickerImage; @Getter @Builder(access = AccessLevel.PRIVATE) public class ReadStickerForUserRes { - private Integer id; - private String name; - private String description; - private Integer price; - private Integer discountRate; - private Integer discountPrice; - private String composition; - private String size; - private Boolean isCustom; - private Integer shippingCost; - private List stickerThemes; - private List stickerStyles; - private List images; - private Boolean productLiked; + private Integer id; + private String name; + private String description; + private Integer price; + private Integer discountRate; + private Integer discountPrice; + private String composition; + private String size; + private Boolean isCustom; + private Integer shippingCost; + private List stickerThemes; + private List stickerStyles; + private String mainImage; + private List detailImages; + private Boolean productLiked; - public static ReadStickerForUserRes of(Sticker sticker, Boolean productLiked) { - List stickerImages = new ArrayList<>(); - List stickerThemes = new ArrayList<>(); - List stickerStyles = new ArrayList<>(); - Integer discountRate = null; - Integer discountPrice = null; + public static ReadStickerForUserRes of(Sticker sticker, Boolean productLiked) { + Integer discountRate = null; + Integer discountPrice = null; - if (!Objects.isNull(sticker.getDiscount())) { - discountRate = sticker.getDiscount().getDiscountRate(); - discountPrice = sticker.getDiscountPrice(); - } - stickerImages.add(sticker.getMainImageUrl()); - sticker.getStickerImages().stream() - .map(image -> stickerImages.add(image.getImageUrl())) - .collect(Collectors.toList()); - sticker.getStickerThemes() - .stream() - .map(theme -> stickerThemes.add(theme.getTheme().getName())) - .collect(Collectors.toList()); - sticker.getStickerStyles() - .stream() - .map(style -> stickerStyles.add(style.getStyle().getName())) - .collect(Collectors.toList()); - return ReadStickerForUserRes.builder() - .id(sticker.getId()) - .name(sticker.getName()) - .description(sticker.getDescription()) - .price(sticker.getPrice()) - .discountRate(discountRate) - .discountPrice(discountPrice) - .composition(sticker.getComposition()) - .size(sticker.getSize()) - .isCustom(sticker.getIsCustom()) - .shippingCost(sticker.getShippingFee()) - .stickerThemes(stickerThemes) - .stickerStyles(stickerStyles) - .images(stickerImages) - .productLiked(productLiked) - .build(); - } + if (!Objects.isNull(sticker.getDiscount())) { + discountRate = sticker.getDiscount().getDiscountRate(); + discountPrice = sticker.getDiscountPrice(); + } + + List stickerImages = sticker.getStickerImages() + .stream() + .map(StickerImage::getImageUrl) + .collect(Collectors.toList()); + + List stickerThemes = sticker.getStickerThemes() + .stream() + .map(theme -> theme.getTheme().getName()) + .collect(Collectors.toList()); + + List stickerStyles = sticker.getStickerStyles() + .stream() + .map(style -> style.getStyle().getName()) + .collect(Collectors.toList()); + + return ReadStickerForUserRes.builder() + .id(sticker.getId()) + .name(sticker.getName()) + .description(sticker.getDescription()) + .price(sticker.getPrice()) + .discountRate(discountRate) + .discountPrice(discountPrice) + .composition(sticker.getComposition()) + .size(sticker.getSize()) + .isCustom(sticker.getIsCustom()) + .shippingCost(3000) + .stickerThemes(stickerThemes) + .stickerStyles(stickerStyles) + .mainImage(sticker.getMainImageUrl()) + .detailImages(stickerImages) + .productLiked(productLiked) + .build(); + } } diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerRes.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerRes.java index 2f57ee57..cb568041 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerRes.java @@ -7,7 +7,7 @@ import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; @Getter @Builder(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryListRes.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryListRes.java index ba92c1cb..fc245f6e 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryListRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryListRes.java @@ -5,7 +5,7 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryRes.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryRes.java index 98855bdd..a4c6fcdd 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerSummaryRes.java @@ -4,7 +4,7 @@ import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; @Getter @Builder(access = AccessLevel.PRIVATE) diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/impl/StickerFacadeImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/impl/StickerFacadeImpl.java index f381e2fe..e4777695 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/impl/StickerFacadeImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/impl/StickerFacadeImpl.java @@ -9,11 +9,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.sticker.domain.StickerImage; -import org.tattour.server.domain.sticker.domain.StickerSort; -import org.tattour.server.domain.sticker.domain.StickerStyle; -import org.tattour.server.domain.sticker.domain.StickerTheme; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.sticker.model.StickerImage; +import org.tattour.server.domain.sticker.model.StickerSort; +import org.tattour.server.domain.sticker.model.StickerStyle; +import org.tattour.server.domain.sticker.model.StickerTheme; import org.tattour.server.domain.sticker.exception.NotFoundStickerSortException; import org.tattour.server.domain.sticker.facade.StickerFacade; import org.tattour.server.domain.sticker.facade.dto.request.CreateStickerReq; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/domain/Sticker.java b/server/src/main/java/org/tattour/server/domain/sticker/model/Sticker.java similarity index 91% rename from server/src/main/java/org/tattour/server/domain/sticker/domain/Sticker.java rename to server/src/main/java/org/tattour/server/domain/sticker/model/Sticker.java index 639b0eee..af8f8736 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/domain/Sticker.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/model/Sticker.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.sticker.domain; +package org.tattour.server.domain.sticker.model; import java.util.ArrayList; import java.util.List; @@ -20,9 +20,8 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; -import org.tattour.server.domain.discount.domain.Discount; -import org.tattour.server.domain.order.domain.Order; -import org.tattour.server.domain.user.domain.ProductLiked; +import org.tattour.server.domain.discount.model.Discount; +import org.tattour.server.domain.order.model.OrderedProduct; import org.tattour.server.global.util.AuditingTimeEntity; @Table(name = "sticker") @@ -77,7 +76,7 @@ public class Sticker extends AuditingTimeEntity { private List stickerImages = new ArrayList<>(); @OneToMany(mappedBy = "sticker") - private List orders = new ArrayList<>(); + private List orderedProducts = new ArrayList<>(); public void applyDiscount(Discount discount) { this.discount = discount; @@ -107,7 +106,4 @@ public static Sticker of( .state(state) .build(); } -} - - - +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerImage.java b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerImage.java similarity index 95% rename from server/src/main/java/org/tattour/server/domain/sticker/domain/StickerImage.java rename to server/src/main/java/org/tattour/server/domain/sticker/model/StickerImage.java index e2d21d06..2a1da7c0 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerImage.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerImage.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.sticker.domain; +package org.tattour.server.domain.sticker.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerSort.java b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerSort.java similarity index 93% rename from server/src/main/java/org/tattour/server/domain/sticker/domain/StickerSort.java rename to server/src/main/java/org/tattour/server/domain/sticker/model/StickerSort.java index 81333ce4..306983d1 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerSort.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerSort.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.sticker.domain; +package org.tattour.server.domain.sticker.model; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerStyle.java b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerStyle.java similarity index 91% rename from server/src/main/java/org/tattour/server/domain/sticker/domain/StickerStyle.java rename to server/src/main/java/org/tattour/server/domain/sticker/model/StickerStyle.java index c1163dff..5d7d21be 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerStyle.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerStyle.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.sticker.domain; +package org.tattour.server.domain.sticker.model; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,7 +13,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.tattour.server.domain.style.domain.Style; +import org.tattour.server.domain.style.model.Style; @Getter @Table(name = "sticker_style") diff --git a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerTheme.java b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerTheme.java similarity index 91% rename from server/src/main/java/org/tattour/server/domain/sticker/domain/StickerTheme.java rename to server/src/main/java/org/tattour/server/domain/sticker/model/StickerTheme.java index 596945b3..b7ec70bf 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/domain/StickerTheme.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/model/StickerTheme.java @@ -1,4 +1,4 @@ -package org.tattour.server.domain.sticker.domain; +package org.tattour.server.domain.sticker.model; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,7 +13,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.tattour.server.domain.theme.domain.Theme; +import org.tattour.server.domain.theme.model.Theme; @Getter @Table(name = "sticker_theme") diff --git a/server/src/main/java/org/tattour/server/domain/sticker/provider/StickerProvider.java b/server/src/main/java/org/tattour/server/domain/sticker/provider/StickerProvider.java index e7431ad4..5973ddaa 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/provider/StickerProvider.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/provider/StickerProvider.java @@ -1,14 +1,18 @@ package org.tattour.server.domain.sticker.provider; import java.util.List; -import org.tattour.server.domain.sticker.domain.Sticker; -import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.sticker.model.Sticker; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; public interface StickerProvider { - // 스티커 엔티티 가져오기 Sticker getById(Integer id); + StickerOrderInfo getStickerOrderInfoFromOrder(int stickerId, int count); + + StickerOrderInfo getStickerOrderInfoFromCart(List carts); + List getAllCustomStickerOrderByOrder(); List getAllByThemeAndStyleOrderByOrder(String theme, String style); @@ -21,6 +25,4 @@ public interface StickerProvider { List getAllByThemeOrStyleOrNameLike(String word); - // 결제 시트에서 스티커 정보 가져오기 - ReadOrderSheetStickerInfo readOrderSheetStickerInfo(Sticker sticker); } diff --git a/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java index 47a52b8c..4160e08e 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/provider/impl/StickerProviderImpl.java @@ -1,14 +1,18 @@ package org.tattour.server.domain.sticker.provider.impl; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.cart.model.Cart; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.exception.NotFoundStickerException; import org.tattour.server.domain.sticker.provider.StickerProvider; -import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo; +import org.tattour.server.domain.sticker.provider.vo.StickerOrderInfo; import org.tattour.server.domain.sticker.repository.StickerRepository; @Slf4j @@ -16,68 +20,67 @@ @RequiredArgsConstructor public class StickerProviderImpl implements StickerProvider { - private final StickerRepository stickerRepository; + private final StickerRepository stickerRepository; - @Override - public Sticker getById(Integer id) { - return stickerRepository.findById(id) - .orElseThrow(NotFoundStickerException::new); - } + @Override + public Sticker getById(Integer id) { + return stickerRepository.findById(id) + .orElseThrow(NotFoundStickerException::new); + } - @Override - public List getAllCustomStickerOrderByOrder() { - return stickerRepository - .findAllByStateAndIsCustomInOrderOrder(); - } + @Override + public StickerOrderInfo getStickerOrderInfoFromOrder(int stickerId, int count) { + return StickerOrderInfo.of(Map.of(getById(stickerId), count)); + } - @Override - public List getAllByThemeAndStyleOrderByOrder(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderOrder(themeName, styleName); - } + @Override + public StickerOrderInfo getStickerOrderInfoFromCart(List carts) { + return carts.stream() + .collect(Collectors.collectingAndThen( + Collectors.toMap( + Cart::getSticker, + Cart::getCount, + Integer::sum, + LinkedHashMap::new), + StickerOrderInfo::of)); + } - @Override - public List getAllByThemeAndStyleOrderByPrice(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderPrice(themeName, styleName); - } + @Override + public List getAllCustomStickerOrderByOrder() { + return stickerRepository + .findAllByStateAndIsCustomInOrderOrder(); + } - @Override - public List getAllByThemeAndStyleOrderByPriceDesc(String themeName, String styleName) { - return stickerRepository - .findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(themeName, styleName); - } + @Override + public List getAllByThemeAndStyleOrderByOrder(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderOrder(themeName, styleName); + } - @Override - public List getAllSameThemeOrStyleById(Integer id) { - return stickerRepository - .findAllSameThemeOrStyleById(id); - } + @Override + public List getAllByThemeAndStyleOrderByPrice(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderPrice(themeName, styleName); + } - @Override - public List getAllByThemeOrStyleOrNameLike(String word) { - if(Objects.isNull(word)) { - return null; - } - return stickerRepository - .findAllByThemeNameOrStyleNameOrNameContaining(word); - } + @Override + public List getAllByThemeAndStyleOrderByPriceDesc(String themeName, String styleName) { + return stickerRepository + .findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(themeName, styleName); + } - // Todo : 리펙토링하기 of -> from? - @Override - public ReadOrderSheetStickerInfo readOrderSheetStickerInfo(Sticker sticker) { - Integer discountedPrice = getDiscountPrice(sticker); - return ReadOrderSheetStickerInfo.of( - sticker.getMainImageUrl(), - sticker.getName(), - sticker.getPrice(), - discountedPrice); - } + @Override + public List getAllSameThemeOrStyleById(Integer id) { + return stickerRepository + .findAllSameThemeOrStyleById(id); + } - private static Integer getDiscountPrice(Sticker sticker) { - if (Objects.isNull(sticker.getDiscount())) { - return null; - } - return (sticker.getPrice() * (100 - sticker.getDiscount().getDiscountRate())) / 100; - } + @Override + public List getAllByThemeOrStyleOrNameLike(String word) { + if (Objects.isNull(word)) { + return null; + } + return stickerRepository + .findAllByThemeNameOrStyleNameOrNameContaining(word); + } } diff --git a/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/ReadOrderSheetStickerInfo.java b/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/ReadOrderSheetStickerInfo.java deleted file mode 100644 index d8c5bb02..00000000 --- a/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/ReadOrderSheetStickerInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.tattour.server.domain.sticker.provider.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.Setter; -import org.tattour.server.domain.sticker.domain.Sticker; - -// Todo: 리펙토링 필요 -@Schema(description = "타투 스티커 정보") -@Getter -@Setter -public class ReadOrderSheetStickerInfo { - - @Schema(description = "메인 배너 이미지", example = "https://tattoo170829.wisacdn.com/data/file/tattoo_posting/833046566_5d1d5fc1db100.jpg") - private String mainImageUrl; - - @Schema(description = "타투 스티커 이름", example = "포효하는 호랑이") - private String name; - - @Schema(description = "가격", example = "3500") - private Integer price; - - @Schema(description = "할인된 가격", example = "3150") - private Integer discountedPrice; - - @Schema(description = "상품 개수", example = "3") - private Integer count; - - private ReadOrderSheetStickerInfo(String mainImageUrl, String name, Integer price, - Integer discountedPrice) { - this.mainImageUrl = mainImageUrl; - this.name = name; - this.price = price; - this.discountedPrice = discountedPrice; - } - - public static ReadOrderSheetStickerInfo of( - String mainImageUrl, - String name, - Integer price, - Integer discountedPrice) { - return new ReadOrderSheetStickerInfo(mainImageUrl, name, price, discountedPrice); - } - - public static ReadOrderSheetStickerInfo from(Sticker sticker) { - return new ReadOrderSheetStickerInfo( - sticker.getMainImageUrl(), - sticker.getName(), - sticker.getPrice(), - sticker.getDiscountPrice()); - } - - public void setCount(int count) { - this.count = count; - } -} diff --git a/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/StickerOrderInfo.java b/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/StickerOrderInfo.java new file mode 100644 index 00000000..48dca1e3 --- /dev/null +++ b/server/src/main/java/org/tattour/server/domain/sticker/provider/vo/StickerOrderInfo.java @@ -0,0 +1,36 @@ +package org.tattour.server.domain.sticker.provider.vo; + +import java.util.Map; +import java.util.Objects; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.tattour.server.domain.sticker.model.Sticker; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class StickerOrderInfo { + + private Map stickerOrderInfos; + + public static StickerOrderInfo of(Map stickerOrderInfo) { + return new StickerOrderInfo(stickerOrderInfo); + } + + public int calculateProductAmount() { + return stickerOrderInfos + .entrySet() + .stream() + .mapToInt(entry -> getFinalProductPrice(entry.getKey()) * entry.getValue()) + .sum(); + } + + private int getFinalProductPrice(Sticker sticker) { + return Objects.isNull(sticker.getDiscountPrice()) + ? sticker.getPrice() : sticker.getDiscountPrice(); + } + + public int calculateTotalAmount(int shippingFee) { + return calculateProductAmount() + shippingFee; + } +} diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerImageRepository.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerImageRepository.java index 157ffc00..4d154881 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerImageRepository.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerImageRepository.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.sticker.repository; -import org.tattour.server.domain.sticker.domain.StickerImage; +import org.tattour.server.domain.sticker.model.StickerImage; public interface StickerImageRepository { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerRepository.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerRepository.java index b44cf359..0c80798e 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerRepository.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerRepository.java @@ -2,7 +2,7 @@ import java.util.Optional; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.repository.custom.StickerRepositoryCustom; public interface StickerRepository extends diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerStyleRepository.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerStyleRepository.java index 6e8dd0f9..9ea548de 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerStyleRepository.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerStyleRepository.java @@ -1,7 +1,6 @@ package org.tattour.server.domain.sticker.repository; -import java.util.List; -import org.tattour.server.domain.sticker.domain.StickerStyle; +import org.tattour.server.domain.sticker.model.StickerStyle; public interface StickerStyleRepository { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerThemeRepository.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerThemeRepository.java index 1c857180..98215cc0 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerThemeRepository.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/StickerThemeRepository.java @@ -1,7 +1,6 @@ package org.tattour.server.domain.sticker.repository; -import java.util.List; -import org.tattour.server.domain.sticker.domain.StickerTheme; +import org.tattour.server.domain.sticker.model.StickerTheme; public interface StickerThemeRepository { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/custom/StickerRepositoryCustom.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/custom/StickerRepositoryCustom.java index 90704a93..7ac78d36 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/custom/StickerRepositoryCustom.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/custom/StickerRepositoryCustom.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.sticker.repository.custom; import java.util.List; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; public interface StickerRepositoryCustom { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerImageRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerImageRepositoryImpl.java index da66c7ec..a3440d5a 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerImageRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerImageRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.sticker.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.sticker.domain.StickerImage; +import org.tattour.server.domain.sticker.model.StickerImage; import org.tattour.server.domain.sticker.repository.StickerImageRepository; public interface StickerImageRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerRepositoryImpl.java index 8dafb280..e953958f 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerRepositoryImpl.java @@ -1,164 +1,164 @@ package org.tattour.server.domain.sticker.repository.impl; -import static org.tattour.server.domain.order.domain.QOrder.*; -import static org.tattour.server.domain.sticker.domain.QSticker.*; -import static org.tattour.server.domain.sticker.domain.QStickerStyle.*; -import static org.tattour.server.domain.sticker.domain.QStickerTheme.*; -import static org.tattour.server.domain.style.domain.QStyle.*; -import static org.tattour.server.domain.theme.domain.QTheme.*; +import static org.tattour.server.domain.order.model.QOrderedProduct.orderedProduct; +import static org.tattour.server.domain.sticker.model.QSticker.sticker; +import static org.tattour.server.domain.sticker.model.QStickerStyle.stickerStyle; +import static org.tattour.server.domain.sticker.model.QStickerTheme.stickerTheme; +import static org.tattour.server.domain.style.model.QStyle.style; +import static org.tattour.server.domain.theme.model.QTheme.theme; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import lombok.RequiredArgsConstructor; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.repository.custom.StickerRepositoryCustom; @RequiredArgsConstructor public class StickerRepositoryImpl implements StickerRepositoryCustom { - private final JPAQueryFactory queryFactory; + private final JPAQueryFactory queryFactory; - @Override - public List findAllByStateAndIsCustomInOrderOrder() { - return queryFactory - .select(sticker) - .from(sticker) - .leftJoin(sticker.orders) - .where(sticker.isCustom.eq(true), sticker.state.eq(true)) - .groupBy(sticker.id) - .orderBy(sticker.orders.size().desc()) - .fetch(); - } + @Override + public List findAllByStateAndIsCustomInOrderOrder() { + return queryFactory + .select(sticker) + .from(sticker) + .leftJoin(sticker.orderedProducts, orderedProduct) + .where(sticker.isCustom.eq(true), sticker.state.eq(true)) + .groupBy(sticker.id) + .orderBy(sticker.orderedProducts.size().desc()) + .fetch(); + } - @Override - public List findAllSameThemeOrStyleById(Integer id) { - return queryFactory - .select(sticker).distinct() - .from(sticker) - .leftJoin(sticker.stickerThemes, stickerTheme) - .leftJoin(sticker.stickerStyles, stickerStyle) - .where(sticker.state.eq(true)) - .where(stickerTheme.theme.in( - queryFactory - .select(stickerTheme.theme) - .from(stickerTheme) - .where(stickerTheme.sticker.id.eq(id)) - ).or(stickerStyle.style.in( - queryFactory - .select(stickerStyle.style) - .from(stickerStyle) - .where(stickerStyle.sticker.id.eq(id)) - ))) - .orderBy(sticker.id.asc()) - .fetch(); - } + @Override + public List findAllSameThemeOrStyleById(Integer id) { + return queryFactory + .select(sticker).distinct() + .from(sticker) + .leftJoin(sticker.stickerThemes, stickerTheme) + .leftJoin(sticker.stickerStyles, stickerStyle) + .where(sticker.state.eq(true)) + .where(stickerTheme.theme.in( + queryFactory + .select(stickerTheme.theme) + .from(stickerTheme) + .where(stickerTheme.sticker.id.eq(id)) + ).or(stickerStyle.style.in( + queryFactory + .select(stickerStyle.style) + .from(stickerStyle) + .where(stickerStyle.sticker.id.eq(id)) + ))) + .orderBy(sticker.id.asc()) + .fetch(); + } - @Override - public List findAllByThemeNameAndStyleNameAndStateInOrderOrder( - String themeName, - String styleName) { - return queryFactory - .select(sticker).distinct() - .from(sticker) - .leftJoin(sticker.stickerThemes, stickerTheme) - .leftJoin(sticker.stickerStyles, stickerStyle) - .leftJoin(sticker.orders, order) - .fetchJoin() - .where(sticker.state.eq(true)) - .where(stickerTheme.theme.in( - queryFactory - .select(theme) - .from(theme) - .where(eqThemeName(themeName)) - ).and(stickerStyle.style.in( - queryFactory - .select(style) - .from(style) - .where(eqStyleName(styleName)) - ))) - .fetch(); - } + @Override + public List findAllByThemeNameAndStyleNameAndStateInOrderOrder( + String themeName, + String styleName) { + return queryFactory + .select(sticker).distinct() + .from(sticker) + .leftJoin(sticker.stickerThemes, stickerTheme) + .leftJoin(sticker.stickerStyles, stickerStyle) + .leftJoin(sticker.orderedProducts, orderedProduct) + .fetchJoin() + .where(sticker.state.eq(true)) + .where(stickerTheme.theme.in( + queryFactory + .select(theme) + .from(theme) + .where(eqThemeName(themeName)) + ).and(stickerStyle.style.in( + queryFactory + .select(style) + .from(style) + .where(eqStyleName(styleName)) + ))) + .fetch(); + } - @Override - public List findAllByThemeNameAndStyleNameAndStateInOrderPrice(String themeName, - String styleName) { - return queryFactory - .select(sticker).distinct() - .from(sticker) - .leftJoin(sticker.stickerThemes, stickerTheme) - .leftJoin(sticker.stickerStyles, stickerStyle) - .leftJoin(sticker.orders, order) - .fetchJoin() - .where(sticker.state.eq(true)) - .where(stickerTheme.theme.in( - queryFactory - .select(theme) - .from(theme) - .where(eqThemeName(themeName)) - ).and(stickerStyle.style.in( - queryFactory - .select(style) - .from(style) - .where(eqStyleName(styleName)) - ))) - .orderBy(sticker.price.asc()) - .fetch(); - } + @Override + public List findAllByThemeNameAndStyleNameAndStateInOrderPrice(String themeName, + String styleName) { + return queryFactory + .select(sticker).distinct() + .from(sticker) + .leftJoin(sticker.stickerThemes, stickerTheme) + .leftJoin(sticker.stickerStyles, stickerStyle) + .leftJoin(sticker.orderedProducts, orderedProduct) + .fetchJoin() + .where(sticker.state.eq(true)) + .where(stickerTheme.theme.in( + queryFactory + .select(theme) + .from(theme) + .where(eqThemeName(themeName)) + ).and(stickerStyle.style.in( + queryFactory + .select(style) + .from(style) + .where(eqStyleName(styleName)) + ))) + .orderBy(sticker.price.asc()) + .fetch(); + } - @Override - public List findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(String themeName, - String styleName) { - return queryFactory - .select(sticker).distinct() - .from(sticker) - .leftJoin(sticker.stickerThemes, stickerTheme) - .leftJoin(sticker.stickerStyles, stickerStyle) - .leftJoin(sticker.orders, order) - .fetchJoin() - .where(sticker.state.eq(true)) - .where(stickerTheme.theme.in( - queryFactory - .select(theme) - .from(theme) - .where(eqThemeName(themeName)) - ).and(stickerStyle.style.in( - queryFactory - .select(style) - .from(style) - .where(eqStyleName(styleName)) - ))) - .orderBy(sticker.price.desc()) - .fetch(); - } + @Override + public List findAllByThemeNameAndStyleNameAndStateInOrderPriceDesc(String themeName, + String styleName) { + return queryFactory + .select(sticker).distinct() + .from(sticker) + .leftJoin(sticker.stickerThemes, stickerTheme) + .leftJoin(sticker.stickerStyles, stickerStyle) + .leftJoin(sticker.orderedProducts, orderedProduct) + .fetchJoin() + .where(sticker.state.eq(true)) + .where(stickerTheme.theme.in( + queryFactory + .select(theme) + .from(theme) + .where(eqThemeName(themeName)) + ).and(stickerStyle.style.in( + queryFactory + .select(style) + .from(style) + .where(eqStyleName(styleName)) + ))) + .orderBy(sticker.price.desc()) + .fetch(); + } - @Override - public List findAllByThemeNameOrStyleNameOrNameContaining(String word) { - return queryFactory - .select(sticker).distinct() - .from(sticker) - .leftJoin(sticker.stickerThemes, stickerTheme) - .leftJoin(sticker.stickerStyles, stickerStyle) - .where(sticker.state.eq(true)) - .where(stickerTheme.theme.in( - queryFactory - .select(theme) - .from(theme) - .where(theme.name.contains(word)) - ).or(stickerStyle.style.in( - queryFactory - .select(style) - .from(style) - .where(style.name.contains(word)) - )).or(sticker.name.contains(word))) - .fetch(); - } + @Override + public List findAllByThemeNameOrStyleNameOrNameContaining(String word) { + return queryFactory + .select(sticker).distinct() + .from(sticker) + .leftJoin(sticker.stickerThemes, stickerTheme) + .leftJoin(sticker.stickerStyles, stickerStyle) + .where(sticker.state.eq(true)) + .where(stickerTheme.theme.in( + queryFactory + .select(theme) + .from(theme) + .where(theme.name.contains(word)) + ).or(stickerStyle.style.in( + queryFactory + .select(style) + .from(style) + .where(style.name.contains(word)) + )).or(sticker.name.contains(word))) + .fetch(); + } - private BooleanExpression eqStyleName(String styleName) { - return styleName == null ? null : style.name.eq(styleName); - } + private BooleanExpression eqStyleName(String styleName) { + return styleName == null ? null : style.name.eq(styleName); + } - private BooleanExpression eqThemeName(String themeName) { - return themeName == null ? null : theme.name.eq(themeName); - } -} + private BooleanExpression eqThemeName(String themeName) { + return themeName == null ? null : theme.name.eq(themeName); + } +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerStyleRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerStyleRepositoryImpl.java index 5542751f..526c0993 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerStyleRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerStyleRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.sticker.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.sticker.domain.StickerStyle; +import org.tattour.server.domain.sticker.model.StickerStyle; import org.tattour.server.domain.sticker.repository.StickerStyleRepository; public interface StickerStyleRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerThemeRepositoryImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerThemeRepositoryImpl.java index 1560af94..66fe47a5 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerThemeRepositoryImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/repository/impl/StickerThemeRepositoryImpl.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.sticker.repository.impl; import org.springframework.data.repository.Repository; -import org.tattour.server.domain.sticker.domain.StickerTheme; +import org.tattour.server.domain.sticker.model.StickerTheme; import org.tattour.server.domain.sticker.repository.StickerThemeRepository; public interface StickerThemeRepositoryImpl extends diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerImageService.java b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerImageService.java index 739bb223..d5f2d217 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerImageService.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerImageService.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.sticker.service; -import org.tattour.server.domain.sticker.domain.StickerImage; +import org.tattour.server.domain.sticker.model.StickerImage; public interface StickerImageService { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerService.java b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerService.java index 7e4d2f69..07ae0e64 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerService.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerService.java @@ -1,7 +1,7 @@ package org.tattour.server.domain.sticker.service; import java.util.List; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; public interface StickerService { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerStyleService.java b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerStyleService.java index 39558d93..2226df7b 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerStyleService.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerStyleService.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.sticker.service; -import org.tattour.server.domain.sticker.domain.StickerStyle; +import org.tattour.server.domain.sticker.model.StickerStyle; public interface StickerStyleService { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerThemeService.java b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerThemeService.java index b8644275..089cac79 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/StickerThemeService.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/StickerThemeService.java @@ -1,6 +1,6 @@ package org.tattour.server.domain.sticker.service; -import org.tattour.server.domain.sticker.domain.StickerTheme; +import org.tattour.server.domain.sticker.model.StickerTheme; public interface StickerThemeService { diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerImageServiceImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerImageServiceImpl.java index 790e96de..f3f7fadf 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerImageServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerImageServiceImpl.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.tattour.server.domain.sticker.domain.StickerImage; +import org.tattour.server.domain.sticker.model.StickerImage; import org.tattour.server.domain.sticker.repository.StickerImageRepository; import org.tattour.server.domain.sticker.service.StickerImageService; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerServiceImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerServiceImpl.java index 3895ce85..ad434f62 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerServiceImpl.java @@ -1,10 +1,9 @@ package org.tattour.server.domain.sticker.service.impl; -import java.util.Collections; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.tattour.server.domain.sticker.domain.Sticker; +import org.tattour.server.domain.sticker.model.Sticker; import org.tattour.server.domain.sticker.repository.StickerRepository; import org.tattour.server.domain.sticker.service.StickerService; @@ -12,15 +11,15 @@ @RequiredArgsConstructor public class StickerServiceImpl implements StickerService { - private final StickerRepository stickerRepository; + private final StickerRepository stickerRepository; - @Override - public Sticker save(Sticker sticker) { - return stickerRepository.save(sticker); - } + @Override + public Sticker save(Sticker sticker) { + return stickerRepository.save(sticker); + } - @Override - public void sortStickerListByNumberOfOrderDesc(List stickers) { - Collections.sort(stickers, (o1, o2) -> o2.getOrders().size() - o1.getOrders().size()); - } -} + @Override + public void sortStickerListByNumberOfOrderDesc(List stickers) { + stickers.sort((o1, o2) -> o2.getOrderedProducts().size() - o1.getOrderedProducts().size()); + } +} \ No newline at end of file diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerStyleServiceImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerStyleServiceImpl.java index 136bad13..54c3772f 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerStyleServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerStyleServiceImpl.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.tattour.server.domain.sticker.domain.StickerStyle; +import org.tattour.server.domain.sticker.model.StickerStyle; import org.tattour.server.domain.sticker.repository.StickerStyleRepository; import org.tattour.server.domain.sticker.service.StickerStyleService; diff --git a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerThemeServiceImpl.java b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerThemeServiceImpl.java index 4c23306d..5b81e34b 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerThemeServiceImpl.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/service/impl/StickerThemeServiceImpl.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.tattour.server.domain.sticker.domain.StickerTheme; +import org.tattour.server.domain.sticker.model.StickerTheme; import org.tattour.server.domain.sticker.repository.StickerThemeRepository; import org.tattour.server.domain.sticker.service.StickerThemeService; diff --git a/server/src/main/java/org/tattour/server/domain/style/facade/dto/response/ReadStyleListRes.java b/server/src/main/java/org/tattour/server/domain/style/facade/dto/response/ReadStyleListRes.java index 6e923425..f80d0881 100644 --- a/server/src/main/java/org/tattour/server/domain/style/facade/dto/response/ReadStyleListRes.java +++ b/server/src/main/java/org/tattour/server/domain/style/facade/dto/response/ReadStyleListRes.java @@ -5,20 +5,20 @@ import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import org.tattour.server.domain.style.domain.Style; +import org.tattour.server.domain.style.model.Style; @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) public class ReadStyleListRes { - List readStyleRes; + List readStyleRes; - public static ReadStyleListRes from(List