Skip to content

Commit

Permalink
#57 [REFACTOR] Point dto rename, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
05AM committed Aug 9, 2023
1 parent 7fc4b49 commit 6fb1bfd
Show file tree
Hide file tree
Showing 36 changed files with 338 additions and 330 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@
import org.tattour.server.domain.order.controller.dto.request.PatchOrderStatusReq;
import org.tattour.server.domain.order.provider.impl.OrderProviderImpl;
import org.tattour.server.domain.order.service.impl.OrderServiceImpl;
import org.tattour.server.domain.point.provider.dto.request.GetPointLogListReq;
import org.tattour.server.domain.point.provider.dto.response.GetPointChargeRequestListRes;
import org.tattour.server.domain.point.provider.dto.response.GetPointLogListRes;
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.impl.PointProviderImpl;
import org.tattour.server.domain.point.service.dto.request.ConfirmPointChargeRequestDto;
import org.tattour.server.domain.order.facade.dto.request.UpdateOrderStatusReq;
import org.tattour.server.domain.point.service.dto.response.ConfirmPointChargeResponseDto;
import org.tattour.server.domain.point.service.impl.PointServiceImpl;
import org.tattour.server.domain.sticker.service.StickerService;
import org.tattour.server.domain.sticker.service.dto.response.StickerInfo;
import org.tattour.server.domain.user.controller.dto.response.LoginRes;
import org.tattour.server.domain.user.controller.dto.response.PostLoginRes;
import org.tattour.server.domain.user.domain.User;
import org.tattour.server.domain.user.provider.impl.UserProviderImpl;
import org.tattour.server.global.config.jwt.JwtService;
Expand Down Expand Up @@ -83,7 +82,7 @@ public class AdminController {
@ApiResponse(
responseCode = "200",
description = "조회에 성공했습니다.",
content = @Content(schema = @Schema(implementation = LoginRes.class))),
content = @Content(schema = @Schema(implementation = PostLoginRes.class))),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청입니다.",
Expand All @@ -106,7 +105,7 @@ public ResponseEntity<?> getOrderHistory(
@ApiResponse(
responseCode = "200",
description = "조회에 성공했습니다.",
content = @Content(schema = @Schema(implementation = GetPointChargeRequestListRes.class))),
content = @Content(schema = @Schema(implementation = ReadPointChargeRequestListRes.class))),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청입니다.",
Expand Down Expand Up @@ -220,7 +219,7 @@ public ResponseEntity<?> cancelPointChargeRequest(
@ApiResponse(
responseCode = "200",
description = "포인트 로그 조회에 성공했습니다.",
content = @Content(schema = @Schema(implementation = GetPointLogListRes.class))),
content = @Content(schema = @Schema(implementation = ReadPointLogListRes.class))),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청입니다.",
Expand All @@ -237,7 +236,7 @@ public ResponseEntity<?> getPointLog(
) {
return BaseResponse.success(
SuccessType.READ_POINT_LOG_SUCCESS,
pointProvider.getPointLog(GetPointLogListReq.of(userId, title)));
pointProvider.getPointLog(userId, title));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@
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.response.GetOrderSheetRes;
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.response.ReadUserOrderHistoryListRes;
import org.tattour.server.domain.point.facade.impl.PointFacadeImpl;
import org.tattour.server.domain.user.facade.impl.UserFacadeImpl;
import org.tattour.server.global.config.resolver.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;
import org.tattour.server.infra.discord.service.DiscordMessageService;

@RestController
@RequestMapping("api/v1/order")
Expand All @@ -47,7 +44,7 @@ public class OrderController {
@ApiResponse(
responseCode = "200",
description = "조회에 성공했습니다.",
content = @Content(schema = @Schema(implementation = GetOrderSheetRes.class))),
content = @Content(schema = @Schema(implementation = ReadOrderSheetRes.class))),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청입니다.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 org.tattour.server.domain.order.provider.vo.OrderAmountInfo;
import org.tattour.server.domain.user.provider.vo.UserPointAfterOrderInfo;
import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo;
@Schema(description = "결제 페이지 불러오기")
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ReadOrderSheetRes {
private ReadOrderSheetStickerInfo readOrderSheetStickerInfo;

private OrderAmountInfo orderAmountInfo;

private UserPointAfterOrderInfo userPointAfterOrderInfo;

public static ReadOrderSheetRes of(
ReadOrderSheetStickerInfo readOrderSheetStickerInfo,
OrderAmountInfo orderAmountInfo,
UserPointAfterOrderInfo userPointAfterOrderInfo) {
return new ReadOrderSheetRes(readOrderSheetStickerInfo, orderAmountInfo,
userPointAfterOrderInfo);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.tattour.server.domain.order.facade;

import org.tattour.server.domain.order.controller.dto.response.GetOrderSheetRes;
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.facade.dto.response.ReadUserOrderHistoryListRes;

public interface OrderFacade {
// 결제 시트 불러오기
GetOrderSheetRes readOrderSheet(ReadOrderSheetReq req);
ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req);

// 주문하기
void createOrder(CreateOrderRequest req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.tattour.server.domain.order.provider.vo.OrderHistoryInfo;
import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo;

@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ReadOrderHistoryListRes {

List<ReadOrderHistoryRes> readOrderHistoryResList;
private PageInfoRes pageInfoRes;
List<OrderHistoryInfo> orderHistoryInfoList;
private OrderHistoryPageInfo orderHistoryPageInfo;

public static ReadOrderHistoryListRes of(List<ReadOrderHistoryRes> readOrderHistoryResList,
PageInfoRes pageInfoRes) {
return new ReadOrderHistoryListRes(readOrderHistoryResList, pageInfoRes);
public static ReadOrderHistoryListRes of(List<OrderHistoryInfo> orderHistoryInfoList,
OrderHistoryPageInfo orderHistoryPageInfo) {
return new ReadOrderHistoryListRes(orderHistoryInfoList, orderHistoryPageInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.tattour.server.domain.order.provider.vo.UserOrderHistoryInfo;

@Schema(description = "user 결제 내역 리스트 Response")
@Getter
Expand All @@ -14,10 +15,10 @@
@AllArgsConstructor
public class ReadUserOrderHistoryListRes {

List<ReadUserOrderHistoryRes> readUserOrderHistoryResList;
List<UserOrderHistoryInfo> userOrderHistoryInfoList;

public static ReadUserOrderHistoryListRes of(
List<ReadUserOrderHistoryRes> readUserOrderHistoryResList) {
return new ReadUserOrderHistoryListRes(readUserOrderHistoryResList);
List<UserOrderHistoryInfo> userOrderHistoryInfoList) {
return new ReadUserOrderHistoryListRes(userOrderHistoryInfoList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.tattour.server.domain.order.controller.dto.response.GetOrderSheetRes;
import org.tattour.server.domain.order.controller.dto.response.ReadOrderSheetRes;
import org.tattour.server.domain.order.domain.Order;
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.response.ReadOrderAmountRes;
import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderPointRes;
import org.tattour.server.domain.order.provider.vo.OrderAmountInfo;
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.provider.impl.OrderProviderImpl;
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.dto.response.ReadOrderSheetStickerInfo;
import org.tattour.server.domain.sticker.provider.vo.ReadOrderSheetStickerInfo;
import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl;
import org.tattour.server.domain.user.provider.impl.UserProviderImpl;
import org.tattour.server.domain.user.service.impl.UserServiceImpl;
Expand All @@ -35,19 +35,17 @@ public class OrderFacadeImpl implements OrderFacade {
private final PointServiceImpl pointService;
private final DiscordMessageService discordMessageService;


// TODO : 메소드 분리하기
@Override
@Transactional
public GetOrderSheetRes readOrderSheet(ReadOrderSheetReq req) {
public ReadOrderSheetRes readOrderSheet(ReadOrderSheetReq req) {
// 스티커 정보(배너이미지, 이름, 원래가격, 할인가격) + 개수
ReadOrderSheetStickerInfo readOrderSheetStickerInfo =
stickerProvider.readOrderSheetStickerInfo(req.getStickerId());
readOrderSheetStickerInfo.setCount(req.getCount());

// 결제 금액 정보
// 총 결제 금액, 총 상품 금액, 배송비
ReadOrderAmountRes readOrderAmountRes =
OrderAmountInfo orderAmountInfo =
orderProvider.readOrderAmountRes(
Objects.isNull(readOrderSheetStickerInfo.getDiscountedPrice())
? readOrderSheetStickerInfo.getPrice()
Expand All @@ -57,13 +55,13 @@ public GetOrderSheetRes readOrderSheet(ReadOrderSheetReq req) {

// 포인트
// 보유 포인트, 남는 포인트
ReadUserOrderPointRes readUserOrderPointRes =
UserPointAfterOrderInfo userPointAfterOrderInfo =
userProvider.readUserPointAfterOrderInfo(
req.getUserId(),
readOrderAmountRes.getTotalAmount());
orderAmountInfo.getTotalAmount());

return GetOrderSheetRes.of(readOrderSheetStickerInfo, readOrderAmountRes,
readUserOrderPointRes);
return ReadOrderSheetRes.of(readOrderSheetStickerInfo, orderAmountInfo,
userPointAfterOrderInfo);
}

@Override
Expand All @@ -77,9 +75,7 @@ public void createOrder(CreateOrderRequest req) {
Order order = orderService.saveOrder(req);

// userPoint 수정
int resultPoint = userService.updateUserPoint(
req.getUserId(),
-req.getTotalAmount());
int resultPoint = userService.updateUserPoint(req.getUserId(), -req.getTotalAmount());

// 포인트 로그 저장
pointService.savePointLog(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tattour.server.domain.order.provider;

import org.tattour.server.domain.order.domain.Order;
import org.tattour.server.domain.order.facade.dto.response.ReadOrderAmountRes;
import org.tattour.server.domain.order.provider.vo.OrderAmountInfo;
import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryListRes;
import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes;

Expand All @@ -20,7 +20,7 @@ public interface OrderProvider {
ReadUserOrderHistoryListRes readOrderHistoryAfterDate(int userId, String date);

// 결제 금액정보 가져오기
ReadOrderAmountRes readOrderAmountRes(int price, int count, int shippingFee);
OrderAmountInfo readOrderAmountRes(int price, int count, int shippingFee);

// 상품 금액 계산
int calculateProductAmount(int price, int count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
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.facade.dto.response.ReadOrderAmountRes;
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.facade.dto.response.ReadOrderHistoryListRes;
import org.tattour.server.domain.order.facade.dto.response.ReadOrderHistoryRes;
import org.tattour.server.domain.order.provider.vo.OrderHistoryInfo;
import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryListRes;
import org.tattour.server.domain.order.facade.dto.response.ReadUserOrderHistoryRes;
import org.tattour.server.domain.order.facade.dto.response.PageInfoRes;
import org.tattour.server.domain.order.provider.vo.OrderHistoryPageInfo;
import org.tattour.server.domain.order.repository.impl.OrderRepositoryImpl;
import org.tattour.server.domain.sticker.provider.impl.StickerProviderImpl;
import org.tattour.server.domain.user.provider.impl.UserProviderImpl;
Expand Down Expand Up @@ -42,44 +42,44 @@ public ReadOrderHistoryListRes readOrderHistoryByPage(int page) {
page - 1,
10,
Sort.by("createdAt")));
List<ReadOrderHistoryRes> readOrderHistoryResList =
List<OrderHistoryInfo> orderHistoryInfoList =
EntityDtoMapper.INSTANCE.toGetOrderHistoryListRes(getOrderHistoryResPage);

return ReadOrderHistoryListRes.of(
readOrderHistoryResList,
PageInfoRes.of(
orderHistoryInfoList,
OrderHistoryPageInfo.of(
page,
getOrderHistoryResPage.getTotalElements(),
getOrderHistoryResPage.getTotalPages()));
}

@Override
public ReadUserOrderHistoryListRes readOrderHistoryByUserId(int userId) {
List<ReadUserOrderHistoryRes> readUserOrderHistoryResList =
List<UserOrderHistoryInfo> userOrderHistoryInfoList =
EntityDtoMapper.INSTANCE
.toGetUserOrderHistoryListRes(orderRepository.findAllByUser_Id(userId));

return ReadUserOrderHistoryListRes.of(readUserOrderHistoryResList);
return ReadUserOrderHistoryListRes.of(userOrderHistoryInfoList);
}

@Override
public ReadUserOrderHistoryListRes readOrderHistoryAfterDate(int userId, String date) {
List<ReadUserOrderHistoryRes> readUserOrderHistoryResList =
List<UserOrderHistoryInfo> userOrderHistoryInfoList =
EntityDtoMapper.INSTANCE
.toGetUserOrderHistoryListRes(
orderRepository.findAllByUser_IdAndCreatedAtAfter(
userId,
date));

return ReadUserOrderHistoryListRes.of(readUserOrderHistoryResList);
return ReadUserOrderHistoryListRes.of(userOrderHistoryInfoList);
}

@Override
public ReadOrderAmountRes readOrderAmountRes(int price, int count, int shippingFee) {
public OrderAmountInfo readOrderAmountRes(int price, int count, int shippingFee) {
int productAmount = calculateProductAmount(price, count);
int totalAmount = calculateTotalAmount(productAmount, shippingFee);

return ReadOrderAmountRes.of(totalAmount, productAmount, shippingFee);
return OrderAmountInfo.of(totalAmount, productAmount, shippingFee);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tattour.server.domain.order.facade.dto.response;
package org.tattour.server.domain.order.provider.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
Expand All @@ -7,7 +7,7 @@
@Schema(description = "결제 금액 정보")
@Getter
@AllArgsConstructor
public class ReadOrderAmountRes {
public class OrderAmountInfo {

@Schema(description = "총 결제금액", example = "12000")
private Integer totalAmount;
Expand All @@ -18,8 +18,8 @@ public class ReadOrderAmountRes {
@Schema(description = "배송비", example = "3000")
private Integer shippingFee;

public static ReadOrderAmountRes of(Integer totalAmount, Integer productAmount,
public static OrderAmountInfo of(Integer totalAmount, Integer productAmount,
Integer shippingFee) {
return new ReadOrderAmountRes(totalAmount, productAmount, shippingFee);
return new OrderAmountInfo(totalAmount, productAmount, shippingFee);
}
}
Loading

0 comments on commit 6fb1bfd

Please sign in to comment.